Dk Izzati Pg Haji Ahmad. Hex Hexadecimal (also base 16, or hex) is a positional numeral system with...

12
Hexadecimal Dk Izzati Pg Haji Ahmad

Transcript of Dk Izzati Pg Haji Ahmad. Hex Hexadecimal (also base 16, or hex) is a positional numeral system with...

Page 1: 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.

Hexadecimal

Dk Izzati Pg Haji Ahmad

Page 2: 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.

HexHexadecimal (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.

Page 3: 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.

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

Page 4: 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.

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

Page 5: 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.

How about the conversion of decimal to hex?

Let’s take a look at the table below.

Example 1:Decimal Numberc Operation Quotient Remainde

r

Hexadecimal Result

1792112

70

÷ 16 =÷ 16 =÷ 16 =DONE.

11270

007

000

700

Page 6: 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.

      

Decimal Number Operation Quotient Remainder

 Hexadecimal Result

488793054190110

÷ 16 =÷ 16 = ÷ 16 =÷ 16 =Done.

3054190110

15141411

FEF

EEFBEEF

Example 2:

Page 7: 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.

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

Page 8: 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.

Hence, the answer for the conversion of AF6D to octal is 1275558

AF6D 1010 1111 0110 1101

Divide the binary every 3-bits starting from

right to left1 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

Page 9: 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.

Exercise

1. Convert the following binary numbers to hexadecimal

a. 0111b. 1101c. 1011011d. 11101100e. 100101101f. 0101101011110000g. 00000000000000000001h. 11001010111001101011010011

Page 10: 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.

2. Convert the following hexadecimal numbers to binary:

a. ADEAb. AF-05-12-57c. 00-00-0C-9F-F2-A9d. 00-00-5E-00-00-00e. 123456789ABCDEFf. F0E1D2C3B4A59687g. B0Ch. 1000

Page 11: 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.

3. Convert the following hexadecimal numbers to decimal:

a. AAb. 123Fc. FEDCBAd. D0-BE-D0e. B8Cf. FF-FF-FF-FAg. 10h. FABE

Page 12: 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.

4. Convert the following decimal numbers to hexadecimal:

a. 9b. 32c. 73d. 255e. 1,025f. 4,099g. 65536h. 1,048,575