Bagaimana cara mengubah desimal ke heksadesimal?
Langkah-langkah Perhitungan untuk bagian Integer:
- Bagilah angka desimal dengan 16.
- Dapatkan hasil bagi bilangan bulat dan gunakan untuk iterasi berikutnya.
- Dapatkan sisanya dan gunakan untuk digit hex.
- Ulangi langkah di atas hingga hasil bagi sama dengan 0, atau setelah sejumlah langkah tertentu.
Langkah-langkah menghitung bagian pecahan:
- Kalikan bagian pecahan dengan 16.
- 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 25.01562510 ke heksadesimal:
Konversi bagian bilangan bulat:
Dibagi dengan 16 | Hasil bagi | Sisa | Bit |
---|
25/16 | 1 | 9 => 9 | 0 |
1/16 | 0 | 1 => 1 | 1 |
Konversi bagian pecahan:
Kalikan dengan 16 | Produk | Sisa | Digit Pecahan |
---|
0.0156*16 | 0.25 | 0.25 | 0 => 0 |
0.25*16 | 4 | 0 | 4 => 4 |
Hasil: 25.01562510 = 19.0416