11 Ramadhan 1435
>> 4-BIT BCD CODES
>> 6-BIT BCD CODES
>> 8-BIT BCD CODES
>> ZONED-DECIMAL & PACKED DECIMAL
FORMATS
INTRODUCTION
HOW DOES A COMPUTER REPRESENT THE NUMERICAL DATA IN
BINARY FORMAT?
Base-2 digits [Straight Binary]
BCD [Binary-Coded Decimal] binary-coded decimal (BCD) - class of binary encodings of decimal numbers In byte-oriented systems (i.e. most modern computers), the term uncompressed BCD usually implies a full byte for each digit
(often including a sign), whereas packed BCD typically encodes two decimal digits within a single byte by taking advantage of the fact that four bits are enough to represent the range 0 to 9.
uncompressed BCD
Decimal
Binary
0000
9
1001
0000
1
0001
packed BCD
Decimal
Binary
9
1001
1
0001
In BCD, a digit is usually represented by 4 bits which, in general, represent the values/digits/characters 0–9.
Types of 4-bit BCD formatted codes
>>Weighted 8-4-2-1 BCD Codes
>>Weighted 4-2-2-1 BCD Codes*
>>Non-weighted XS-3 BCD Codes
Excess-3 was used on some older computers as well as in cash registers and hand held portable electronic calculators of the 1970's, among other uses. It is a way to represent values with a balanced number of positive and negative numbers using a pre-specified number N as a biasing value. It is a nonweighted code. In XS-3, numbers are represented as decimal digits, and each digit is represented by four bits as the digit value plus 3 (the "excess" amount):
DECIMAL DIGITS
4-BIT BCD CODES
8-4-2-1
XS-3
0
0000
0011
1
0001
0100
2
0010
0101
3
0011
0110
4
0100
0111
5
0101
1000
6
0110
1001
7
0111
1010
8
1000
1011
9
1001
1100
Table : the binary representation for 4-bit codes
Example 2
What is the non-weighted BCD representation for 46910 in a computer’s memory cells?
PRINCIPLE : Add 310 = 00112 for each decimal digit represented by the
8-4-2-1 BCD codes.
Decimal Digit
4
6
9
8-4-2-1 BCD Codes
0100
0110
1001
Add
310 = 00112
+ 0011
0011
0011