Bagaimana cara mengkonversi dari desimal ke biner?
Langkah-langkah Perhitungan untuk bagian Integer:
- Bagilah angka desimal dengan 2.
- Dapatkan hasil bagi bilangan bulat dan gunakan untuk iterasi berikutnya.
- Dapatkan sisanya dan gunakan untuk digit biner.
- Ulangi langkah di atas hingga hasil bagi sama dengan 0, atau setelah sejumlah langkah tertentu.
Langkah-langkah menghitung bagian pecahan:
- Kalikan bagian pecahan dengan 2.
- Ambil bagian bilangan bulat dari hasil kali sebagai angka pecahan. Ambil bagian pecahan produk untuk iterasi berikutnya.
- Ulangi langkah di atas hingga bagian pecahan menjadi 0, atau berhenti setelah beberapa langkah jika bagian pecahan tidak menjadi 0.
Contoh:
Mengubah 15.37510 ke biner:
Konversi bagian bilangan bulat:
Dibagi dengan 2 | Hasil bagi | Sisa | Bit |
---|
15/2 | 7 | 1 | 0 |
7/2 | 3 | 1 | 1 |
3/2 | 1 | 1 | 2 |
1/2 | 0 | 1 | 3 |
Konversi bagian pecahan:
Kalikan dengan 2 | Produk | Sisa | Digit Pecahan |
---|
0.375*2 | 0.75 | 0.75 | 0 |
0.75*2 | 1.5 | 0.5 | 1 |
0.5*2 | 1 | 0 | 1 |
Hasil: 15.7510 = 1111.0112