Skip to content · ⁨Pular para o conteúdo⁩

Denary to binary · ⁨Decimal para binário⁩

English

Denary to binary

Go the other way: from a denary number to its binary digits.

Divide by 2 again and again. The remainder n % 2 is the next bit, and n // 2 is what is left to convert. The remainders come out right to left, so put each new bit at the front of the string. 0 needs its own answer, because the loop would never run.

Português

Decimal para binário

Faça o caminho inverso: de um número decimal para seus dígitos binários.

Divida por 2 repetidamente. O resto n % 2 é o próximo bit, e n // 2 é o que sobra para converter. Os restos aparecem da direita para a esquerda, então coloque cada novo bit na frente da string. 0 precisa de sua própria resposta, pois o loop nunca executaria.

Log in or create account · ⁨Entrar ou criar conta⁩

IGCSE, A-Level & AP