Skip to content · ⁨Saltar al contenido⁩

Denary to binary · ⁨Decimal a binario⁩

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.

Español

De decimal a binario

Hacer el proceso inverso: de un número decimal a sus dígitos binarios.

Dividir por 2 una y otra vez. El resto n % 2 es el siguiente bit, y n // 2 es lo que queda por convertir. Los restos aparecen de derecha a izquierda, así que colocar cada nuevo bit al principio de la cadena. El 0 necesita su propia respuesta, porque el bucle nunca se ejecutaría.

Log in or create account · ⁨Iniciar sesión o crear cuenta⁩

IGCSE, A-Level & AP