Convert decimal to binary in Scratch

1

Why not display the result on the screen? I tried to convert decimal to binary number in Scratch, but it is not working. Can anyone see what the error is?

    
asked by anonymous 21.05.2018 / 19:34

1 answer

1
The best solution to generate the binary digits is to use a list to store the digits and a looping to reduce the entradaUsuario variable at each iteration.

At each iteration of looping , the algorithm extracts the binary digit through a remainder division operation by 2 and stores that digit in the list.

Then divide entradaUsuario by 2 until it reaches zero.

Follow the algorithm below:

LinktotheprojectontheScratchsite: Decimal for Binary

If you really need to get the digits into separate variables, simply run the algorithm without looping by repeating the code for the number of binary digits you need:

    
21.05.2018 / 23:17