• No results found

Number and codes in digital systems

N/A
N/A
Protected

Academic year: 2021

Share "Number and codes in digital systems"

Copied!
5
0
0

Loading.... (view fulltext now)

Full text

(1)

B431 – Principles of Digital Systems : Hassan Parchizadeh Page 1

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

1x8 + 0x4 + 1x2 + 1x1

3 2 1 0 1x2 + 0x2 + 1x2 + 1x2 and for 10.001 (binary) = 10.0012

(2)

B431 – Principles of Digital Systems : Hassan Parchizadeh Page 2

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 / 2 = 18 remainder 1____________ LSB 18 / 2 = 9 remainder 0__________ !

9 / 2 = 4 remainder 1________ ! ! 4 / 2 = 2 remainder 0______ ! ! ! 2 / 2 = 1 remainder 0____ ! ! ! !

1 / 2 = 0 remainder 1 __ ! ! ! ! ! MSB ! ! ! ! ! !

1 0 0 1 0 1 Binary equivalent of 37

Example : Convert 0.3125 decimal into binary.

0.3125 x 2 = 0.625 Carry 0 __ MSB 0.625 x 2 = 1.25 Carry 1 __!__

0.25 x 2 = 0.50 Carry 0 __!__!__

0.5 x 2 = 1.00 Carry 1 __!__!__!__ LSB ! ! ! !

.0 1 0 1 equivalent of 0.312 Problem : Convert the following decimals to binary form. :

i. 23 ii. 49 iii) 2.525

(3)

B431 – Principles of Digital Systems : Hassan Parchizadeh Page 3

Binary Arithmetic

All the digital computers and microprocessors work on a binary basis, processing numbers and instructions coded in 1 and 0 patterns. Binary arithmetic is very similar to normal decimal arithmetic , perhaps even easir, since we are only dealing with 0's and 1's. The four operations are shown below :-

Addition Substraction Multiplication Division

0 + 0 = 0 0 - 0 = 0 0 x 0 = 0 0 + 1 = 1 0 - 1 = 1 C=1 0 x 1 = 0 0 / 1 = 0 1 + 0 = 1 1 - 0 = 1 1 x 0 = 0 1 + 1 = 0 C=1 1 - 1 = 0 1 x 1 = 1 1 / 1 = 1

C = Carry / Borrow

Example : Perform binary i. Addition ii. Subtraction iii. Multiplication

and iv. Division on the 110 and 10 binary numbers.

11

i) 110 + ii) 110 - iii) 110 x iv) 10 | 110 10 10 10 10

1000 100 000 10

110 10

1100 00

Signed Numbers Digital Systems, such as the computer, must be able to handle both positive and negative numbers. A signed binary number consists of both sign and magnitude information. There are three ways in which signed numbers can be represented. Sign-magnitude numbers : 00001010 = + 10

10001010 = - 10

In the sign-magnitude system, the negative and positive numbers have the same magnitude, but the sign bit(MSB) is 1 for negative numbers. 1'S Complements of Binary Numbers 00001010 = + 10

11110101 = - 10

(4)

B431 – Principles of Digital Systems : Hassan Parchizadeh Page 4

positive numbers are represented in the same way as sign-magnitude numbers, but the negative numbers are 1's complement of the positive number. . The 1'S complement is found by simply changing all 1s to 0s and all 0s to 1s.

2'S Complements of Binary Numbers 00001010 = + 10

11110101 +  1's complement 1

11110110 = -10  2's complement

The 2'S complement is found by adding 1 to 1'S complement. In computers, the 2's complement system is the most widely used for handling signed numbers.

Problem :Determine the 2'S complement for each 8-bit binary number.

i. 00110111 ii. 11110000 iii. 10101010

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.

Hexadecimal to Binary conversion Consider 1A34

0001 1010 0011 0100  11010001101002

Problem : Determine the binary numbers for i. 345616 and ii. CDEF16 .

(5)

B431 – Principles of Digital Systems : Hassan Parchizadeh Page 5

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  LSB 40 / 16 = 2 remainder 810 = 816

2 / 16= 0 remainder 210 = 216  MSB

28A16 hexadecimal equivalent of 65010

Problem : Determine the hexadecimal numbers for i. 5679010 and ii. 2100010 .

Note to Students : Also look at BCD (Binary Coded Decimal) and Gray Codes.

References

Related documents