BCD: binary-coded decimal

advertisement
UNSIGNED BINARY AND
BINARY-CODED DECIMAL
REPRESENTING INTEGER
DATA
BCD: binary-coded decimal
• Each decimal digit individually converted
to binary
– Requires 4 bits per digit
⇒ 8-bit location hold 2 BCD digits — 00 to 99
6810 ≡ 01101000BCD
• Hexa: 4 bits can hold 16 ≠ values, 0 to F
• A to F not used in BCD
1
SIGN-AND-MAGNITUDE
REPRESENTATION
Nine’s Decimal Representation
Examples 9’s complement
• 9’s compl. Repr. For:
™3-digit nb –467?
999
467
532
™4-digit nb –467?
9999
467
9532
• Sign-and-magnitude value 9990?
9999
9990
9
• 9990 represents the value –9
2
Figure 4.6 Addition as a counting process
Figure 4.7 Addition with wraparound
One’s complement
Figure 4.8 Addition with modulus crossing
3
Add in 1’s complement
Overflow
Ten’s complement scale
Overflow sign of result ≠ sign both operands
4
Examples
Two’s complement
• 10’s complement of
™247 is 1000 – 247 = 753
™17 is 1000 – 017 = 983
• Sign and magnitude of 777
™Begins with a 7 (≥ 5) ⇒ negative
™1000 – 777 = 223
™The sign-magnitude value is –223
• Alternative 10’s comp = 9’s comp + 1
• 2’s complement = 1’s complement+1
Examples of 2’s complement
5
Download