View Single Post
Old 2005-09-13, 03:41   #5
cheesehead
 
cheesehead's Avatar
 
"Richard B. Woods"
Aug 2002
Wisconsin USA

170148 Posts
Default

Quote:
Originally Posted by tinhnho
1. A 16-bit register in a computer contains 10110011 11000100. What does its contents represent if it contains
a) a 4-digit decimal number in the BCD(binary coded decimal) code
0 (decimal) = 0000 (BCD)
1 (decimal) = 0001 (BCD)
2 (decimal) = 0010 (BCD)
3 (decimal) = 0011 (BCD)
4 (decimal) = 0100 (BCD)
5 (decimal) = 0101 (BCD)
6 (decimal) = 0110 (BCD)
7 (decimal) = 0111 (BCD)
8 (decimal) = 1000 (BCD)
9 (decimal) = 1001 (BCD)

The register content 1011 0011 1100 0100 is not itself a 4-digit BCD number because neither 1011 nor 1100 is a BCD digit.

BCD also interpreted the other 6 bit sequences as plus or minus signs -- 1011 and 1101 were minus signs, while 1010, 1100, 1110 and 1111 were plus signs. (Yes, two codes for the minus sign and four codes for the plus sign.)
(Why not three codes for each sign? (*sigh*) It's a long story.)

So, 1011 0011 1100 0100 could be interpreted as BCD "-3+4", but that's not a 4-digit decimal number.

- - -

And yes, packed decimal format is derived from BCD codes -- even the plus/minus signs (in IBM's packed decimal, anyway).

Last fiddled with by cheesehead on 2005-09-13 at 03:44
cheesehead is offline   Reply With Quote