100 likes | 408 Vues
BCD = Binary Coded Decimal. Representing numbers. Integers 2’s complement is most popular BCD Real numbers Floating point IEEE 754 standard format is most popular Fixed point 2’s complement integers (using standard integer arithmetic) BCD All of the above are supported by IA32!.
E N D
Representing numbers • Integers • 2’s complement is most popular • BCD • Real numbers • Floating point • IEEE 754 standard format is most popular • Fixed point • 2’s complement integers (using standard integer arithmetic) • BCD • All of the above are supported by IA32!
BCD = binary coded decimal 4 bit encoding of 0..9 (decimal) base 10 base 2 BCD 0 0000 0000 same 1 0000 0001 " 2 0000 0010 " 3 0000 0011 " 4 0000 0100 " 5 0000 0101 " 6 0000 0110 " 7 0000 0111 " 8 0000 1000 " 9 0000 1001 " 10 0000 1010 0001 0000 11 0000 1011 0001 0001 12 0000 1100 0001 0010 . . . ? ? ?
BCD = binary coded decimal 4 bit encoding of 0..9 (decimal) base 10 base 2 BCD 0 0000 0000 same 1 0000 0001 " 2 0000 0010 " 3 0000 0011 " 4 0000 0100 " 5 0000 0101 " 6 0000 0110 " 7 0000 0111 " 8 0000 1000 " 9 0000 1001 " 10 0000 1010 0001 0000 11 0000 1011 0001 0001 12 0000 1100 0001 0010 … … … 99 0110 0011 1001 1001 100 0110 0100 invalid … … invalid 255 1111 1111 invalid
Why BCD? • What happened when we converted 0.10 (base 10) to base 2? 0.10 x 2 = 0.20 .0 0.20 x 2 = 0.40 0 0.40 x 2 = 0.80 0 0.80 x 2 = 0.60 1 0.60 x 2 = 0.20 1 . . .
Binary and BCD addition Add 9 + 1.