Skip to content · ⁨Lompat ke konten⁩

Denary to binary · ⁨Desimal ke biner⁩

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.

Bahasa Indonesia

Desimal ke biner

Lakukan sebaliknya: dari bil desimal menuju digit binernya.

Bagi dengan 2 lagi dan lagi. Sisa n % 2 adalah bit berikutnya, dan n // 2 adalah sisa yang harus dikonversi. Sisa-sisa keluar dari kanan ke kiri, jadi tempatkan setiap bit baru di depan string. 0 memerlukan jawabannya sendiri, karena perulangan tidak akan pernah berjalan.

Log in or create account · ⁨Masuk atau buat akun⁩

IGCSE, A-Level & AP