Number Systems - Binary and Hexadecimal Systems

Total Page:16

File Type:pdf, Size:1020Kb

Number Systems - Binary and Hexadecimal Systems

Number Systems – Binary, Octal, Decimal, and Hexadecimal

Basic Number Systems and Conversions

Binary  Base or radix 2 number system  Binary digit is called a bit.  Numbers are 0 and 1 only.  Numbers are expressed as powers of 2.  20 = 1, 21 = 2, 22 = 4, 23 = 8, 24 = 16, 25 = 32, 26 = 64, 27 = 128, 28 = 256, 29 = 512, 210 = 1024, 211 = 2048, 212 = 4096, 212 = 8192, …

Conversion of binary to decimal ( base 2 to base 10) Example: convert (110011)2 to decimal = (1 x 25) + (1 x 24) + (0 x 23) + (0 x 22) + (1 x 21) + (1 x 20) = 32 + 16 + 0 + 0 + 2 + 1 = (51)10

Conversion of decimal to binary (base 10 to base 2) Example: convert (51)10 to binary 51  2 = 25 remainder is 1 25  2 = 12 remainder is 1 12  2 = 6 remainder is 0 6  2 = 3 remainder is 0 3  2 = 1 remainder is 1 1  2 = 0 remainder is 1

Answer = 1 1 0 0 1 1 Note: the answer is read from bottom (MSB) to top (LSB) as 1100112

Octal  Base or radix 8 number system  1 octal digit is equivalent to 3 bits.  Numbers are 0-7.  Numbers are expressed as powers of 8. 80 = 1, 81 = 8, 82 = 64, 83 = 512, 84 = 4096.

Number Systems - 1 Conversion of octal to decimal ( base 8 to base 10) Example: convert (632)8 to decimal = (6 x 82) + (3 x 81) + (2 x 80) = (6 x 64) + (3 x 8) + (2 x 1) = 384 + 24 + 2 = (410)10

Conversion of decimal to octal (base 10 to base 8) Example: convert (177)10 to octal 177  8 = 22 remainder is 1 22  8 = 2 remainder is 6 2  8 = 0 remainder is 2 Note: the answer is read from bottom to top as (261)8, the same as with the binary case.

Hexadecimal  Base or radix 16 number system  1 hex digit is equivalent to 4 bits.  Numbers are 0-9, A, B, C, D, E, and F.  (A)16 = (10)10, (B)16 = (11)10, (C)16 = (12)10, (D)16 = (13)10, (E)16 = (14)10, (F)16 = (15)10  Numbers are expressed as powers of 16.  160 = 1, 161 = 16, 162 = 256, 163 = 4096, 164 = 65536, …

Conversion of hexadecimal to decimal ( base 16 to base 10) Example: convert (F4C)16 to decimal = (F x 162) + (4 x 161) + (C x 160) = (15 x 256) + (4 x 16) + (12 x 1) = 3840 + 64 + 12 = (3916)10

Conversion of decimal to hex (base 10 to base 16) Example: convert (77)10 to hex 77  16 = 4 remainder is D 4  16 = 0 remainder is 4 Note: the answer is read from bottom to top as (4D)16, the same as with the binary case.

Number Systems - 2 decimal hexadecimal binary decimal hexadecimal binary

0 0 0000 16 10 00010000 1 1 0001 17 11 00010001 2 2 0010 18 12 00010010 3 3 0011 19 13 00010011 4 4 0100 20 14 00010100 5 5 0101 21 15 00010101 6 6 0110 22 16 00010110 7 7 0111 23 17 00010111 8 8 1000 24 18 00011000 9 9 1001 25 19 00011001 10 A 1010 26 1A 00011010 11 B 1011 27 1B 00011011 12 C 1100 28 1C 00011100 13 D 1101 29 1D 00011101 14 E 1110 30 1E 00011110 15 F 1111 31 1F 00011111

Table 1: Decimal, hexadecimal and binary numbers

Conversion of Octal and Hex to Binary

Conversion of octal and hex numbers to binary is based upon the the bit patterns shown in the table above and is straight forward. For octal numbers, only three bits are required. Thus 68 = 1102, and 3458 = 111001012. For hex numbers, four bits are required. Thus E16 = 11102, and 47D16 = 100011111012.

Conversion of Binary to Octal and Hex

Conversion of binary numbers to octal and hex simply requires grouping bits in the binary numbers into groups of three bits for conversion to octal and into groups of four bits for conversion to hex. Groups are formed beginning with the LSB and progressing to the MSB. Thus, 111001112 = 3478 and 111000101010100100012 = 70252218. Similarly, 111001112 = E716 and 110001010100001112 = 18A8716.

DECIMAL NUMBER SYSTEM Number Systems - 3 Decimal system is a BASE TEN system It uses 10 symbols: 0,1,2,3,4,5,6,7,8,9

Expand the decimal number 6,458

6,458 = ( 6 x 103 )+ ( 4 x 102 )+ ( 5 x 101 )+ ( 8 x 100 ) Series of additions

Decimal place values 105 104 103 102 101 100 100,000 10,000 1,000 100 10 1 Hundred Ten Thousands Hundreds Tens Ones Thousands Thousands

Binary number system is said to be a Base Two Number of symbols—2 Symbols “0” and “1” A bit in the binary system is like a digit in the decimal system

211 210 29 28 27 26 25 24 23 22 21 20 2048 1024 512 256 128 64 32 16 8 4 2 1

3 2 1 0 11002 = ( 1 x 2 )+ ( 1 x 2 )+ ( 0 x 2 )+ ( 0 x 2 ) = 8 + 4 + 0 + 0 = 1210

4 3 2 1 0 100012 = (1 x 2 ) + ( 0 x 2 )+ ( 0 x 2 )+ ( 0 x 2 )+ ( 1 x 2 ) = 16 + 0 + 0 + 0 + 1 = 1710

5 4 3 2 1 0 1010112= (1 x 2 ) + (0 x 2 ) + ( 1 x 2 )+ ( 0 x 2 )+ ( 1 x 2 )+ ( 1 x 2 ) = 32 + 0 + 8 + 0 + 2 + 1 = 4310 5 4 3 2 1 0 1111012= (1 x 2 ) + (1 x 2 ) + ( 1 x 2 )+ ( 1 x 2 )+ ( 0 x 2 )+ ( 1 x 2 ) = 32 + 16 + 8 + 4 + 0 + 1 = 6110

1102 = 610

10102 = 1010 Number Systems - 4 1100002 = 4810

111112 = 3110

211 210 29 28 27 26 25 24 23 22 21 20 2048 1024 512 256 128 64 32 16 8 4 2 1

710 = 1 1 1 = 1112

3410 = 1 0 0 0 1 0 = 1000102

8910 = 1 0 1 1 0 0 1 = 10110012

20310 = 1 1 0 0 1 0 1 1 = 110010112

1910 = 1 0 0 1 1 = 100112

2210 = 1 0 1 1 0 = 101102

1510 = 1 1 1 1 = 11112

3610 = 1 0 0 1 0 0 = 1001002

4810 = 1 1 0 0 0 0 = 1100002

3910 = 1 0 0 1 1 1 = 1001112

6410 = 1 0 0 0 0 0 0 = 10000002

10310 = 1 1 0 0 1 1 1 = 11001112

EXAMPLE: 710 = 1112 because 7- 4 = 3 3 – 2 = 1 1 - 1= 0

Hexadecimal number system is a Base Sixteen Number of symbols—16 Symbols 0,1,2,3,4,5,6,7,8,9, A, B, C, D, E, F Number Systems - 5 10, 11, 12, 13, 14, 15

1611 1610 169 168 167 166 165 164 163 162 161 160 16,777,21 1,048,57 65,536 4,096 256 16 1 6 6

1 0 7216 = ( 7 x 16 )+ ( 2 x 16 ) = 112 + 2 = 11410

3 2 1 0 235916 = ( 2 x 16 )+ ( 3 x 16 )+ ( 5 x 16 )+ ( 9 x 16 ) = 8192 + 768 + 80 + 9 = 904910

2 1 0 C2916 = ( C x 16 )+ ( 2 x 16 )+ ( 9 x 16 ) = 3072 + 32 + 9 = 311310

3 2 1 0 12AB16 = ( 1 x 16 )+ ( 2 x 16 )+ ( 10 x 16 )+ ( 11 x 16 ) = 4096 + 512 + 160 + 11 = 477910

3 2 1 0 3AC216 = ( 3 x 16 )+ ( 10 x 16 )+ ( 12 x 16 )+ ( 2 x 16 ) = 12288 + 2560 + 192 + 2 = 1504210

Number Systems - 6 Allowable symbols 0, 1, 2, 3, 4,5, 6, 7, 8, 9, A, B, C, D, E, F 10, 11, 12, 13, 14, 15

166 165 164 163 162 161 160 16,777,216 1,048,576 65,536 4096 256 16 1

67210 = 2 A 0 = 2A016

1,76310 = 6 E 3 = 6E316

1,32410 = 5 2 C = 52C16

43,98110 = A B C D = ABCD16

993,85110 = F 2 A 3 B = F2A3B16

12,76010 = 3 1 D 8 = 31D816

For example:

672 1763 2 @ 256 -512 6 @ 256 -1536 160 227 10 @ 16 -160 14 @ 16 -224 0 3

2A016 6E316

1324 43,981 5 @ 256 -1280 10 @ 4096 - 40,960 44 3021 2 @ 16 - 32 11 @ 256 - 2816 12 205 52C16 12 @ 16 -192 13

ABCD16

Number Systems - 7 1010 1100b 1110 1001 b 0110 1011 b 0100 1100 10 12 14 9 6 11 4 12 A C E 9 6 B 4 C ACh E9h 6Bh 4Ch

0011 1111b 0001 1000b 0101 1010b 1101 0111 3 15 1 8 5 10 13 7 3 F 1 8 5 A D 7 3Fh 18h 5Ah D7h

83h 57h 21h ABh 1000 0011b 0101 0111b 0010 0001b 1010 1011b

3Ch 4Fh DBh EEh 0011 1100b 0100 1111b 1101 1011b 1110 1110b

Number Systems - 8

Recommended publications