Idea Transcript
Number and codes in digital systems Decimal Numbers You are familiar with the decimal number system because you use them everyday. But their weighted structure is not understood. In the decimal number system each of the ten digits, 0 through 9, represents a certain quantity (or weight ). These are base TEN numbers. Consider
5678 5x1000 + 6x100 + 7 x10 + 8 x 1 3 2 1 0 5x10 + 6x10 + 7x10 + 8x10
and for 18.25 1x10 + 8x1 + 2 x0.1 + 5 x .01 1 0 -1 -2 1x10 + 8x10 + 2x10 + 5x10 Problem : Express the following as the sum of values of each digit.
1234
=
23.345
=
0.00231
=
Binary Numbers The binary number system is another way of counting and it is simpler than the decimal system, since it has only two digits( 0 and 1). These are base TWO numbers. Consider
1011 (binary) = 10112
ENG330 – Electrical Engineering : Hassan Parchizadeh
Page 1
1x8 + 0x4 + 1x2 + 1x1 3 2 1 0 1x2 + 0x2 + 1x2 + 1x2 and for 10.001 (binary) = 10.0012 1x2 + 0x1 + 0x0.5 + 0x .25 + 1x0.125 1 0 -1 -2 -3 1x2 + 0x2 + 0x2 + 0x2 + 1x2
Problem : Express the following as the sum of values of each digit.
1001101
=
1100.00101
=
0.001101
=
Decimal To Binary Conversion We can convert a decimal number into a binary equivalent by dividing the decimal number successively by 2 and noting the remainders. The equvalent number is then found by writing these remainders in the REVERSE order. Example : Convert 37 decimal into binary. 37 18 9 2 2 1
/ / / / / /
2 = 18 2= 9 2= 4 2= 2 2= 1 2= 0
remainder 1____________ remainder 0__________ ! remainder 1________ ! ! remainder 0______ ! ! ! remainder 0____ ! ! ! ! remainder 1 __ ! ! ! ! ! ! ! ! ! ! ! 1 0 0 1 0 1
LSB
MSB Binary equivalent of 37
ENG330 – Electrical Engineering : Hassan Parchizadeh
Page 2
Example : Convert 0.325 decimal into binary. 0.3125 0.625 0.25 0.5
x x x x
2= 2= 2= 2=
0.625 1.25 0.50 1.00
Carry Carry Carry Carry
0 __ 1 __!__ 0 __!__!__ 1 __!__!__!__ ! ! ! !
.0
MSB
LSB
1 0 1 equivalent of 0.312
Problem : Convert the following decimals to binary form. : a)23
b)49
c)2.35
ENG330 – Electrical Engineering : Hassan Parchizadeh
Page 3
Hexadecimal Numbers The hexadecimal system has a base of 16, that is composed of 16 digits (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E and F) where A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15. Hexadecimal to Decimal conversion Consider 1A34 3 2 1 0 1x16 + 10x16 + 3x16 + 4x16 670810 Problem : Express i. 1234 and ii. ABCD as the sum of values of each digit. i.1234
ii.ABCD
Hexadecimal to Binary conversion Consider 1A34 0001 1010 0011 0100 11010001101002 Problem : Determine the binary numbers for i. 345616 and ii. CDEF16 . i.3456
ii.CDEF
ENG330 – Electrical Engineering : Hassan Parchizadeh
Page 4
Binary to Hexadecimal conversion Consider 100,1110,0110,0100 4 E 6 4 4E6416 Problem : Determine the hexadecimal numbers for the following. i. 100000001100010001
ii. 110101110010001110110
Decimal To Hexadecimal Conversion We can convert a decimal number into a hexadecimal equivalent by dividing the decimal number succesively by 16 and noting the remainders. The equvalent number is then found by writing these remainders in the REVERSE order. Example : Convert 37 decimal into binary. 650 / 16 = 40 remainder 1010 = A16 40 / 16 = 2 remainder 810 = 816 2 / 16= 0 remainder 210 = 216
LSB MSB
28A16 hexadecimal equivalent of 65010 Problem : Determine the hexadecimal numbers for i. 167010 and ii. 210010 . i.1670
ii.2100
ENG330 – Electrical Engineering : Hassan Parchizadeh
Page 5