Binary-coded decimal

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{FormatInfo |formattype=electronic |subcat=Binary Data }} Binary-coded decimal ('''BCD''') is a family of methods to encode decimal numbers in binary data formats. It is ...")
 
(Category:Number formats)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{FormatInfo
 
{{FormatInfo
 
|formattype=electronic
 
|formattype=electronic
|subcat=Binary Data
+
|subcat=Elements of File Formats
 
}}
 
}}
 
[[Binary-coded decimal]] ('''BCD''') is a family of methods to encode decimal numbers in binary data formats. It is not particularly common, though it used to be more common than it is now.
 
[[Binary-coded decimal]] ('''BCD''') is a family of methods to encode decimal numbers in binary data formats. It is not particularly common, though it used to be more common than it is now.
  
It is inefficient compared to purely base-2 number formats, but it can be useful when accurate decimal calculations are needed.
+
It is inefficient compared to purely [[Base2|base-2]] number formats, but it can be useful when accurate decimal calculations are needed.
 +
 
 +
[[EBCDIC]] was derived from IBM's forms of BCD, expanded to encompass non-numeric characters.
  
 
== Format ==
 
== Format ==
Line 34: Line 36:
 
|9 || 1001
 
|9 || 1001
 
|}
 
|}
 +
 +
The other possible codes, starting with 1010, are unused and invalid.
  
 
Two digits are usually packed into a single byte, though there can be just be one digit per byte, among other possible encodings.
 
Two digits are usually packed into a single byte, though there can be just be one digit per byte, among other possible encodings.
Line 39: Line 43:
 
== Links ==
 
== Links ==
 
* [[Wikipedia:Binary-coded decimal|Wikipedia article]]
 
* [[Wikipedia:Binary-coded decimal|Wikipedia article]]
 +
 +
[[Category:Number formats]]

Latest revision as of 15:35, 16 September 2017

File Format
Name Binary-coded decimal
Ontology
Binary-coded decimal (BCD) is a family of methods to encode decimal numbers in binary data formats. It is not particularly common, though it used to be more common than it is now.

It is inefficient compared to purely base-2 number formats, but it can be useful when accurate decimal calculations are needed.

EBCDIC was derived from IBM's forms of BCD, expanded to encompass non-numeric characters.

[edit] Format

Each decimal digit is encoded in four bits:

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

The other possible codes, starting with 1010, are unused and invalid.

Two digits are usually packed into a single byte, though there can be just be one digit per byte, among other possible encodings.

[edit] Links

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox