Hexadecimal Dk Izzati Pg Haji Ahmad
Hex Hexadecimal (also base 16, or hex) is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0–9 to represent values zero to nine, and A, B, C, D, E, F (or alternatively a through f) to represent values 10 - 15. For example, the hexadecimal number 2AF3 is equal, in decimal, to (2 × 163) + (10 × 162) + (15 × 161) + (3 × 160) , or 10,995. Each hexadecimal digit represents four binary digits, and the primary use of hexadecimal notation is as a human-friendly representation of binary coded values in computing and digital electronics. For example, byte values can range from 0 to 255 (decimal) but may be more conveniently represented as two hexadecimal digits in the range 00 through FF.
Conversion of binary to hex Given a binary number, in order to convert it to a hex number, first of all, split the binary number into groups of 4 bits starting from the right. Example: 10011011₂ 1001 1011 Hence, 10011011₂ = 9B₁₆ 9 B
= (2 x 16³) + (10 x 16²) + (15 x 16¹) + (3 x 16⁰) Conversion of hex to decimal To convert hex to decimal, there are more than 1 alternative but the easiest way is to multiply each figure of the hex digit with 16ⁿ starting with the power of 0 (starts from the rightmost). Confusing? Let’s take a look at the example below: Example: Given a hex number 2AF3, convert it to a decimal. 2AF3 = (2 x 16³) + (10 x 16²) + (15 x 16¹) + (3 x 16⁰) = 8192 + 2560 + 240 + 3 = 10,995 The power of 16 should start from 0 and not 1 and it should begin from the rightmost of the hex number. The hex digit represented by an alphabet should be expand to a decimal number
How about the conversion of decimal to hex? Let’s take a look at the table below. Example 1: Decimal Numberc Operation Quotient Remainder Hexadecimal Result 1792 112 7 ÷ 16 = DONE. 00 700
Example 2: 48879 3054 190 11 ÷ 16 = Done. 15 14 F EF EEF BEEF Example 2: Decimal Number Operation Quotient Remainder Hexadecimal Result 48879 3054 190 11 ÷ 16 = Done. 15 14 F EF EEF BEEF
Conversion of hex to octal To convert a hexadecimal number to an octal number, the first thing to do is to convert the hex number into something which is common between the two numeral system: BINARY. Each hex digit is represented by 4-bits binary E.g.: Convert AF6D to an octal. A = 10 = 1010 F = 15 = 1111 6 = 0110 D = 13 = 1101 Hence, AF6D = 1010111101101101 An octal number is represented by 3-bits binary. Hence, starting from the right most side, divide the number above (hex converted to binary) into 3-bits binary. 1010111101101101 1 010 111 101 101 101
Hence, the answer for the conversion of AF6D to octal is 1275558 1010 1111 0110 1101 Divide the binary every 3-bits starting from right to left 1 010 111 101 101 101 ADD 0 to the last set if it is not exactly 3-bits 001 010 111 101 101 101 Change each set of 3-bits into decimal 1 2 7 5 5 5
Exercise 1. Convert the following binary numbers to hexadecimal a Exercise 1. Convert the following binary numbers to hexadecimal a. 0111 b. 1101 c. 1011011 d. 11101100 e. 100101101 f. 0101101011110000 g. 00000000000000000001 h. 11001010111001101011010011
2. Convert the following hexadecimal numbers to binary: ADEA AF-05-12-57 00-00-0C-9F-F2-A9 00-00-5E-00-00-00 123456789ABCDEF F0E1D2C3B4A59687 B0C 1000
3. Convert the following hexadecimal numbers to decimal: a. AA b. 123F c. FEDCBA d. D0-BE-D0 e. B8C f. FF-FF-FF-FA g. 10 h. FABE
4. Convert the following decimal numbers to hexadecimal: 9 32 73 255 1,025 4,099 65536 1,048,575