Minggu, 20 Januari 2013

Binary Conversion

Binary to Hexadecimal

● Divide the binary number into sets of 4 digits. Add leading zeros as needed. For example, write the binary number
11101100101001 as 0011 1011 0010 1001.
● Use the following table to convert each 4-digit binary string to a single hex digit: 0001 (1), 0010 (2), 0011 (3), 0100 (4), 0101 (5), 0110 (6), 0111 (7), 1000 (8), 1001 (9), 1010 (A), 1011 (B), 1100 (C), 1101 (D), 1110 (E), and 1111 (F). The digits in () are the hex equivalents to the preceding binary number.
● Remove the space and you will get your hexadecimal number

Hexadecimal to Decimal
● Write out the hexadecimal in its expanded form.
● For example, 1A2B3C16 becomes
1*165+10*164+2*163+11*162+3*161+12*160
● Evaluate the sum in decimal = 1715004
● You can then convert the decimal to Binary

Decimal to Hexadecimal
● Divide the decimal number by 16. Treat the division as an integer division.
● Write down the remainder (in hexadecimal, ie. if the remainder is 12, write down "C") from right to left. If the remainder is 0, then write the result and stop.
● Divide the result again by 16. Treat the division as an integer division.
● Repeat step 2 and 3 until result is less than 1.
● You get your hexadecimal equivalent

1 komentar: