Skip to content · ⁨Passer au contenu⁩

Denary to binary · ⁨Décimal vers binaire⁩

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.

Français

Décimal vers binaire

Faire l'inverse : d'un nombre décimal vers ses chiffres binaires.

Diviser par 2 encore et encore. Le reste n % 2 est le prochain bit, et n // 2 est ce qui reste à convertir. Les restes apparaissent de droite à gauche, donc placez chaque nouveau bit au début de la chaîne. 0 nécessite sa propre réponse, car la boucle ne s'exécuterait jamais.

Log in or create account · ⁨Se connecter ou créer un compte⁩

IGCSE, A-Level & AP