Reverse binary number scratch

Asked

Viewed 481 times

0

The binary number is coming out reversed, someone knows how to solve the same?

inserir a descrição da imagem aqui

1 answer

0

To reverse the order of the bits, simply change the operator adicione (0 ou 1) a lista (that will always add at the end of the list) inside the block if/or by the operator insira (0 ou 1) na posição 1 da lista (which will add the calculated bit at the beginning of the list).

The project stays this way:

Imagem do programa em Scratch que converte de decimal para binário e mostra os bits na ordem correta

See the project working here: Decimal for Binary 2


Explaining better, the calculated bit at each iteration is the always the least significant (LSB), therefore, when adding it to the list, it appears "inverted" and, changing the add to insert operation, the bits will be placed in the order "correct".

LSB (Wikipedia in English): Least significant bit

Browser other questions tagged

You are not signed in. Login or sign up in order to post.