# Number Conversion

**Topics:**Binary-coded decimal, Binary numeral system, Hexadecimal

**Pages:**27 (3476 words)

**Published:**March 4, 2013

BINARY CODED DECIMAL: B.C.D.

• ANOTHER METHOD TO REPRESENT DECIMAL NUMBERS • USEFUL BECAUSE MANY DIGITAL DEVICES PROCESS + DISPLAY NUMBERS IN TENS

IN BCD EACH NUMBER IS DEFINED BY A BINARY CODE OF 4 BITS. *** 8 – 4 – 2 – 1 MOST COMMON CODE 8 – 4 – 2 – 1 CODE INDICATES THE WEIGHT OF EACH BIT 23 – 22 – 21 – 20 E.G. 934 = 1001 0011 0100 9 3 4 FOR EACH DIGIT A BINARY [NORMAL] CODE IS ALLOCATED. OHER REPRESENTATION FORMS ARE 2-4-2-1 AND EXCESS-3

Ovidiu Ghita

Page 77

Digital Electronics, 2003

BINARY 8-4-2-1 2-4-2-1 EXCESS-3 NOT USED 0000 0 0 NOT USED 0001 1 1 NOT USED 0010 2 2 0011 3 3 0 0100 4 4 1 NOT USED 0101 2 5 NOT USED 0110 3 6 NOT USED 0111 4 7 NOT USED 1000 5 8 NOT USED 1001 6 9 NOT USED NOT USED 1010 7 NOT USED 1011 5 8 NOT USED 1100 6 9 NOT USED NOT USED 1101 7 NOT USED NOT USED 1110 8 NOT USED NOT USED 1111 9 • WE WILL USE 8-4-2-1 BCD • DECIMAL NUMBERS > 9 MAY BE OBTAINED WHEN ADDING TWO DECIMAL DIGITS (RANGE: 0-18) I.E. 0 + 0 ÷ 9 + 9. ONLY 0o9 HAVE THE CORRECT BCD CODE. • WE NEED TO CORRECT THE OTHERS

Ovidiu Ghita Page 78

Digital Electronics, 2003

DECIMAL UNCORECTED CORRECTED BCD SUM BCD SUM C’3 S’3 S’2 S’1 S’0 CN S3 S2 S1 S0 0 0 0 0 0 0 0 0 0 9 10 11 12 13 14 15 16 17 18 19 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 1 1 0 0 1 1 0 0 1 1 1 0 1 0 1 0 1 0 1 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 1 1 0 0 1 1 0 0 1 0 1 0 1 0 1 0 1 0 1

1 1 1 1

1 1 1 1 1 1 1 1 1 1

• 0o9 ONLY LEGAL CODES

E.G. 19 = 1 9 = 0001 1001 = 11001 THUS, FOR SUMS BETWEEN 10 o 18 MUST SUBTRACT 10 AND PRODUCE A CARRY SUBTRACT 10 = 10102 COMPLEMENT = 0110 >> ADD 2’s

Ovidiu Ghita

Page 79

Digital Electronics, 2003

4-BIT BCD ADDER

TO ADD TWO DIGITS FOR SUMS >9 WE NEED TO ADD 2’s COMPLEMENT of 1010 TO THE UNCORRECTED RESULT (S’3 S’2 S’1 S’0) CORRECTION IS ALSO NEEDED WHEN A CARRY OUT (C’3) IS GENERATED [NUMBERS 16 o 18] >>>> A DECODER IS REQUIRED TO DETECT WHEN CARRY OUT (CN) TO THE NEXT STAGE IS NEEDED K-MAP FOR CN S’1S’0 S’3S’2

00 01 11 10

00 01 11 10

0 4 12 8

1 3 2 5 7 6 13 15 14 9 11 10

>>> CN = C’3 + S’3S’2 +S’3S’1

Ovidiu Ghita Page 80

Digital Electronics, 2003

TO IMPLEMENT A 4_BIT BCD ADDER WE NEDD TWO 4-BIT FULL ADDERS, ONE TO ADD TWO 4-BIT BCD NUMBERS AND THE OTHER FULL ADDER TO ADD 2’s COMPLEMENT OF 1010 TO THE RESULT IF CN = 1 ALSO WE NEED 2 AND GATES AND ONE OR GATE TO GENERATE CN B3 A3 B2 A2 B1 A1 B0 A0

' C3

COUT 4 BIT ADDER S'3 S'1 S'2 0

S'0 0

CN-1

FROM NEXT LOWER DIGIT CN= 0 FOR L.S. DIGIT

CN TO NEXT HIGHER DIGIT

4 BIT ADDER

0

S3

S2

S1

S0

• ADD 0110 WHEN CN=1 • ADD 0000 WHEN CN=0

Ovidiu Ghita

Page 81

Digital Electronics, 2003

BCD SUBTRACTION

9’s COMPLEMENT

THE 9’s COMPLEMENT OF A DECIMAL NUMBER IS FOUND BY SUBTRACTING EACH DIGIT IN THE NUMBER FROM 9 DECIMAL DIGIT 9’s COMPLEMENT

0 1 2 9

9 8 7 0

E.G. 9’s COMPLEMENT of 28 = 99 –28 = 71 9’s COMPLEMENT of 562 = 999 –562 = 437 SUBTRACTION OF A SMALLER DECIMAL NUMBER FROM A LARGER ONE CAN BE DONE BY ADDING THE 9’s COMPLEMENT OF THE SMALLER NUMBER TO THE LARGER NUMBER AND THEN ADDING THE CARRY TO THE RESULT (END AROUND CARRY). Ovidiu Ghita Page 82

Digital Electronics, 2003

WHEN SUBTRACTING A LARGER NUMBER FROM A SMALLER ONE THERE IS NO CARRY AND THE RESULT IS IN 9’s COMPLEMENT FORM AND NEGTIVE. EXAMPLES: (a) +8 -3 5 +8 +6 (1) 4 +1 5 54 78 (1) 32 +1 33 9’s COMP. OF 3

END AROUND CARRY

(b)

54 -21 33

9’s COMP. OF 3

END AROUND CARRY

(c)

15 -28 -13

15 9’s COMP. OF 3 +71 86 o -13

NO CARRY >>> NEGATIVE RESULT 86 – 99 = – 13

Ovidiu Ghita Page 83

Digital Electronics, 2003

BCD SUBTRACTION

RECALL FOR DECIMAL SUBTRACTION: A – B = A + [9’s COMPLEMENT OF B] • SIMILARLY FOR BCD

RULES:

(a) ADD 9’s COMP. OF B TO A (b) IF RESULT > 9, CORRECT BY ADDING 0110 (c) IF MOST SIGNIFICANT CARRY IS PRODUCED [i.e. =1] THEN THE RESULT IS POSITIVE AND THE END ARROUND CARRY MUST BE ADDED. (d) IF MOST SIGNIFICANT CARRY...

Please join StudyMode to read the full document