assurance-tunnel
assurance-tunnel
assurance-tunnel
assurance-tunnel

# [SOLVED] Decimal to binary

• Dear all,

It's my first-time use javascript actor, I try to write a decimal to binary actor but I think it over my skill. (I haven't learn java yet...)

Is there anyone can help?

I would like to input number range 0-360 (decimal), then output binary 000000000~000101101(binary).

Thank you!!!

HY

• @huangyi

Here you go. decimalToBinary.izz

Best Michel

• Thank you so much Michel!!!

But my version is 2.61, how can I get newer version? ~@@~

HY

Best Michel

• Thank you so much Michel! It works!

Is it possible to program it to keep export 9 numbers? say 0 = 000000000, 1 = 100000000, 359 = 111001101

Please correct me if I am wrong!

And is there any way that to transfer the number to text? so I can chop the number that I want to send to other actors? It appear differently with number to text actor.

Thank you again!

Wishes,

HY

• @huangyi have a look at this patch you will find michel example modified to output a string

and some other actors that will already decode the bits and output them as 0/1 or on/off

best clemens

dec_binary_ck.izz

• probably I miss something but is I enter 512 (increasing the number of bits ) the javascripts and the text actor return all 0s

what am I missing?

• @maximortal

Well the problem with the modified patch is that its limited to output 9 numbers only, the first number gets chopped off. You have to go into the JavaScript actor and change (-9) to (-10).

Best Michel

• @Maximortal 512 is using the 10th bit so it wouldn't show up in the actors as they are hardcoded to 9 bits as requested by hunagyi

best clemens

• Just because we are talking about binary here.

I found a video on youtube explaining binary, its in german but I guess even just the pictures explain it without understanding the language. Its the best I have seen.

if you don't understand German start watching from 1min 12seconds.

• Thank you, Michel and m_theater!!!

It works perfectly!
I hope I understand German; the video described so beautifully.

Will share with you that I use Isadora to control a turntable!
The actor you wrote which is for the position the 360 degrees of the turntable. Without this actor, I need to type in the binary numbers manually. This actor improved the workflow very much!

I used to ask the turntable engineer to includes this code in their system, but they didn't. Now I luckily improved my coding skill.

Thank you again!

HY

• @huangyi

That sounds awesome! It'd be great to see it in action too! We'd love it if you could tag us when and if you share any photos or videos on social media so that we can share them with our followers too. We're always excited to see what our users around the world create with Isadora and love to celebrate our community! #troikatronix

• Sure! I will do that!  : D

Cheers,

HY

• Dear All + @Michel

Michel discovered an interesting bug in his actor that converts to binary, and I wanted to leave a record of it here.

He tried to convert the number 290 to binary, which should be 100100010. But the output shows 100100018.

Inside the actor, this is being processed as a 32 bit floating point value. But 100100010 cannot be correctly represented by a 32 bit float.

You can see that closest value to 100100010 is 10010008. Thus the error.

In Isadora 3 we use 64 bit floats, and so you won't see this problem until the number gets much larger once you're using that version. But, suffice to say, there is a limit even with 64 bit floating point numbers.

Best Wishes,
Mark

• I still had a few questions to @Mark because you did get a correct output in certain cases. He gave me the following answer:

When the output is text, the conversion is done inside Javascript, where the floating point number stays in the 64 bit space. That produces a correct string result.

The JS actor outputs as integer by default, connect it to a text actor to mutate the output to text.

Best Michel