How to convert binary to decimal?

Hello,
any idea how to convert a binary value to decimal?

example: in Excel BIN2DEC(10011100) = 156

How can I do it with KNIME?

Thanks in advance.

Gery

Hi @Gery,

you could use the java snippet String binaryInputString=“1010”;
int decimal=Integer.parseInt(binaryInputString,2);

But maybe there is an official conversion node.
Did you check the math


Or column expression node, if there are functions for this?

Thanks @AnotherFraudUser,
I checked both the nodes you suggest but I can’t find funcions that sounds like “toDecimal” or “Binaryto”. Probably, I’m searching for the wrong funcion in those nodes.

I tried to compile the Java Snippet node but something go wrong (syntax error). Do you have an example?

Many thanks for the support.

Gery

Hi @Gery,

attached a small example.
KNIME_project18.knwf (6.3 KB)

Please make sure that the input type is string!
(e.g. use number to string beforehand if you have the binary value as integer)

*did not find a function in the math/column expressions either :frowning:
Maybe someone else knows if there is somewhere a hidden funtion :slight_smile:

4 Likes

Thank you @AnotherFraudUser!

It works fine!

Gery

2 Likes

Great! :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.