# Binary-coded decimal

## Redirected from BCD

*32,472*pages on

this wiki

## Definition Edit

**Binary-coded decimal** is a format for representing decimal numbers (integers) in which each digit is represented by four bits.

## Overview Edit

To encode a decimal number using the common BCD encoding, each decimal digit is stored in a 4-bit nibble:

Decimal: 0 1 2 3 4 5 6 7 8 9 BCD: 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001

Thus, the BCD encoding for the number 127 would be:

0001 0010 0111

Whereas the pure binary number would be:

0111 1111

Since most computers store data in 8-bit bytes, there are two common ways of storing 4-bit BCD digits in those bytes:

- each digit is stored in one nibble of a byte, with the other nibble being set to all zeros, all ones (as in the EBCDIC code), or to 0011 (as in the ASCII code)

Unlike binary-encoded numbers, BCD-encoded numbers can easily be displayed by mapping each of the nibbles to a different character. Converting a binary-encoded number to decimal for display is much harder, as this generally involves integer multiplication or divide operations. BCD also avoids problems where fractions that can be represented exactly in decimal cannot be represented in binary (e.g., one-tenth).

## See also Edit

This page uses Creative Commons Licensed content from Wikipedia (view authors). |