Difference between revisions of "BCD"

From CDOT Wiki
Jump to: navigation, search
 
Line 13: Line 13:
 
BCD is extensively used on IBM midrange and mainframe systems. Extended Binary Coded Decimal Interchange Code (EBCDIC) is a character encoding based on BCD used as an alternative to ASCII.
 
BCD is extensively used on IBM midrange and mainframe systems. Extended Binary Coded Decimal Interchange Code (EBCDIC) is a character encoding based on BCD used as an alternative to ASCII.
  
BCD is also used in some accounting programs, to avoid errors that can be introduced through the use of floating-point math. Some CPUs, such as the 6502, support a BCD math mode.
+
BCD is also used in some accounting programs, to avoid errors that can be introduced through the use of floating-point math.
 +
 
 +
Some microcomputer CPUs, such as the [[6502]], support a BCD math mode.

Latest revision as of 17:34, 3 February 2020

Binary coded decimal is a binary representation of decimal numbers where each nibble (4 bits) in a word represents a separate decimal digit.

For example, in BCD, the value 128 would be represented in a 16-bit value as:

Binary:    0 0 0 0     0 0 0 1      0 0 1 0     1 0 0 0
Decimal:         0           1            2           8

(Note that, in traditional binary integer representation, the same binary number represents the decimal value 296).

In signed BCD values, the highest-order nibble is usually used to hold the sign (0 for positive, non-0 for negative).

BCD is extensively used on IBM midrange and mainframe systems. Extended Binary Coded Decimal Interchange Code (EBCDIC) is a character encoding based on BCD used as an alternative to ASCII.

BCD is also used in some accounting programs, to avoid errors that can be introduced through the use of floating-point math.

Some microcomputer CPUs, such as the 6502, support a BCD math mode.