Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Binary-coded decimal
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=={{anchor|Unpacked BCD|NBCD|8421|8-4-2-1}}Background== BCD takes advantage of the fact that any one decimal numeral can be represented by a four-bit pattern. An obvious way of encoding digits is ''Natural BCD'' (NBCD), where each decimal digit is represented by its corresponding four-bit binary value, as shown in the following table. This is also called "8421" encoding. {| class="wikitable" style="text-align:center;" |- ! scope="col" rowspan="2" | Decimal digit ! scope="col" colspan="4" | BCD |- ! 8 !! 4 !! 2 !! 1 |- | 0 || 0 || 0 || 0 || 0 |- | 1 || 0 || 0 || 0 || 1 |- | 2 || 0 || 0 || 1 || 0 |- | 3 || 0 || 0 || 1 || 1 |- | 4 || 0 || 1 || 0 || 0 |- | 5 || 0 || 1 || 0 || 1 |- | 6 || 0 || 1 || 1 || 0 |- | 7 || 0 || 1 || 1 || 1 |- | 8 || 1 || 0 || 0 || 0 |- | 9 || 1 || 0 || 0 || 1 |} This scheme can also be referred to as ''Simple Binary-Coded Decimal'' (''SBCD'') or ''BCD 8421'', and is the most common encoding.<ref name="Evans_1961"/> Others include the so-called "4221" and "7421" encoding – named after the weighting used for the bits – and "[[Excess-3]]".<ref name="Lala_2007"/> For example, the BCD digit 6, {{code|0110'b}} in 8421 notation, is {{code|1100'b}} in 4221 (two encodings are possible), {{code|0110'b}} in 7421, while in Excess-3 it is {{code|1001'b}} (<math>6 + 3 = 9</math>). {| class="wikitable" style="text-align:center;" |+ 4-bit BCD codes and pseudo-tetrades ! Bit !! Weight !! style="background:lightgray"| 0 !! style="background:lightgray"| 1 !! style="background:lightgray"| 2 !! style="background:lightgray"| 3 !! style="background:lightgray"| 4 !! style="background:lightgray"| 5 !! style="background:lightgray"| 6 !! style="background:lightgray"| 7 !! style="background:lightgray"| 8 !! style="background:lightgray"| 9 !! style="background:lightgray"|10 !! style="background:lightgray"|11 !! style="background:lightgray"|12 !! style="background:lightgray"|13 !! style="background:lightgray"|14 !! style="background:lightgray"|15 !! Comment |- | 4 || style="background:lightgray"|8 || 0 || 0 || 0 || 0 || 0 || 0 || 0 || 0 || style="background:#0FF"|1 || style="background:#0FF"|1 || style="background:#0FF"|1 || style="background:#0FF"|1 || style="background:#0FF"|1 || style="background:#0FF"|1 || style="background:#0FF"|1 || style="background:#0FF"|1 || rowspan="4"|'''Binary''' |- | 3 || style="background:lightgray"|4 || 0 || 0 || 0 || 0 || style="background:#0FF"|1 || style="background:#0FF"|1 || style="background:#0FF"|1 || style="background:#0FF"|1 || 0 || 0 || 0 || 0 || style="background:#0FF"|1 || style="background:#0FF"|1 || style="background:#0FF"|1 || style="background:#0FF"|1 |- | 2 || style="background:lightgray"|2 || 0 || 0 || style="background:#0FF"|1 || style="background:#0FF"|1 || 0 || 0 || style="background:#0FF"|1 || style="background:#0FF"|1 || 0 || 0 || style="background:#0FF"|1 || style="background:#0FF"|1 || 0 || 0 || style="background:#0FF"|1 || style="background:#0FF"|1 |- | 1 || style="background:lightgray"|1 || 0 || style="background:#0FF"|1 || 0 || style="background:#0FF"|1 || 0 || style="background:#0FF"|1 || 0 || style="background:#0FF"|1 || 0 || style="background:#0FF"|1 || 0 || style="background:#0FF"|1 || 0 || style="background:#0FF"|1 || 0 || style="background:#0FF"|1 |- | colspan="19"| |- | colspan="2"|'''Name''' || style="background:lightgray"|0 || style="background:lightgray"|1 || style="background:lightgray"|2 || style="background:lightgray"|3 || style="background:lightgray"|4 || style="background:lightgray"|5 || style="background:lightgray"|6 || style="background:lightgray"|7 || style="background:lightgray"|8 || style="background:lightgray"|9 || style="background:lightgray"|10 || style="background:lightgray"|11 || style="background:lightgray"|12 || style="background:lightgray"|13 || style="background:lightgray"|14 || style="background:lightgray"|15 || '''Decimal''' |- | colspan="19"| |- | colspan="2"|'''8 4 2 1 (XS-0)''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:#0FF"|2 || style="background:#0FF"|3 || style="background:#0FF"|4 || style="background:#0FF"|5 || style="background:#0FF"|6 || style="background:#0FF"|7 || style="background:#0FF"|8 || style="background:#0FF"|9 || style="background:gray"|10 || style="background:gray"|11 || style="background:gray"|12 || style="background:gray"|13 || style="background:gray"|14 || style="background:gray"|15 || <!-- <ref name="Kautz_1954"/> --><ref name="Steinbuch_1962"/><!-- <ref name="Steinbuch-Wagner_1967"/><ref name="Steinbuch-Weber-Heinemann_1974"/> --><ref name="Kämmerer_1969"/><ref name="Dokter_1973"/><ref name="Dokter_1975"/><ref group="nb" name="Non-BCD"/> |- | colspan="19"| |- | {{anchor|7421}}colspan="2"|'''7 4 2 1''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:#0FF"|2 || style="background:#0FF"|3 || style="background:#0FF"|4 || style="background:#0FF"|5 || style="background:#0FF"|6 || style="background:gray"| || style="background:#0FF"|7 || style="background:#0FF"|8 || style="background:#0FF"|9 || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:gray"| || <ref name="Kautz_1954"/><ref name="Chinal_1973"/><ref name="MIL_1991"/> |- | colspan="19"| |- | colspan="2"|'''{{nowrap|[[Aiken code|Aiken]] (2 4 2 1)}}''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:#0FF"|2 || style="background:#0FF"|3 || style="background:#0FF"|4 || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:#0FF"|5 || style="background:#0FF"|6 || style="background:#0FF"|7 || style="background:#0FF"|8 || style="background:#0FF"|9 || <!-- <ref name="Kautz_1954"/> --><ref name="Steinbuch_1962"/><!-- <ref name="Steinbuch-Wagner_1967"/><ref name="Steinbuch-Weber-Heinemann_1974"/> --><ref name="Kämmerer_1969"/><ref name="Dokter_1973"/><ref name="Dokter_1975"/><ref group="nb" name="Aiken_2421"/> |- | colspan="19"| |- | colspan="2"|'''{{nowrap|[[Excess-3 code|Excess-3]] (XS-3)}}''' || style="background:gray"|-3 || style="background:gray"|-2 || style="background:gray"|-1 || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:#0FF"|2 || style="background:#0FF"|3 || style="background:#0FF"|4 || style="background:#0FF"|5 || style="background:#0FF"|6 || style="background:#0FF"|7 || style="background:#0FF"|8 || style="background:#0FF"|9 || style="background:gray"|10 || style="background:gray"|11 || style="background:gray"|12 || <!-- <ref name="Kautz_1954"/> --><ref name="Steinbuch_1962"/><!-- <ref name="Steinbuch-Wagner_1967"/><ref name="Steinbuch-Weber-Heinemann_1974"/> --><ref name="Kämmerer_1969"/><ref name="Dokter_1973"/><ref name="Dokter_1975"/><ref group="nb" name="Non-BCD"/> |- | colspan="19"| |- | colspan="2"|'''{{nowrap|[[Excess-6 code|Excess-6]] (XS-6)}}''' || style="background:gray"|-6 || style="background:gray"|-5 || style="background:gray"|-4 || style="background:gray"|-3 || style="background:gray"|-2 || style="background:gray"|-1 || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:#0FF"|2 || style="background:#0FF"|3 || style="background:#0FF"|4 || style="background:#0FF"|5 || style="background:#0FF"|6 || style="background:#0FF"|7 || style="background:#0FF"|8 || style="background:#0FF"|9 || <ref name="Kautz_1954"/><ref group="nb" name="Non-BCD"/> |- | colspan="19"| |- | {{anchor|Jump-at-2}}colspan="2"|'''Jump-at-2 (<!-- special -->2 4 2 1)''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:#0FF"|2 || style="background:#0FF"|3 || style="background:#0FF"|4 || style="background:#0FF"|5 || style="background:#0FF"|6 || style="background:#0FF"|7 || style="background:#0FF"|8 || style="background:#0FF"|9 || <ref name="Dokter_1973"/><ref name="Dokter_1975"/> |- | colspan="19"| |- | {{anchor|Jump-at-2}}colspan="2"|{{nowrap|'''Jump-at-8 (<!-- unsymmetrical -->2 4 2 1)'''}} || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:#0FF"|2 || style="background:#0FF"|3 || style="background:#0FF"|4 || style="background:#0FF"|5 || style="background:#0FF"|6 || style="background:#0FF"|7 || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:#0FF"|8 || style="background:#0FF"|9 || <ref name="Stopper_1960"/><ref name="Borucki-Dittmann_1971"/><ref name="Dokter_1973"/><ref name="Dokter_1975"/><ref group="nb" name="Unsymmetrical_2421"/> |- | colspan="19"| |- | {{anchor|4221}}colspan="2"|{{nowrap|'''4 2 2 1 (I)'''}} || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:#0FF"|2 || style="background:#0FF"|3 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|4 || style="background:#0FF"|5 || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:#0FF"|6 || style="background:#0FF"|7 || style="background:#0FF"|8 || style="background:#0FF"|9 || <ref name="Dokter_1973"/><ref name="Dokter_1975"/> |- | colspan="19"| |- | {{anchor|4221 II}}colspan="2"|{{nowrap|'''4 2 2 1 (II)'''}} || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:#0FF"|2 || style="background:#0FF"|3 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|4 || style="background:#0FF"|5 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|6 || style="background:#0FF"|7 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|8 || style="background:#0FF"|9 || <ref name="Stopper_1960"/><ref name="Borucki-Dittmann_1971"/> |- | colspan="19"| |- | {{anchor|5421}}colspan="2"|'''5 4 2 1''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:#0FF"|2 || style="background:#0FF"|3 || style="background:#0FF"|4 || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:#0FF"|5 || style="background:#0FF"|6 || style="background:#0FF"|7 || style="background:#0FF"|8 || style="background:#0FF"|9 || style="background:gray"| || style="background:gray"| || style="background:gray"| || <ref name="Kautz_1954"/><ref name="Steinbuch_1962"/><!-- <ref name="Steinbuch-Wagner_1967"/><ref name="Steinbuch-Weber-Heinemann_1974"/> --><ref name="Dokter_1973"/><ref name="Dokter_1975"/> |- | colspan="19"| |- | {{anchor|5221}}colspan="2"|'''5 2 2 1''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:#0FF"|2 || style="background:#0FF"|3 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|4 || style="background:gray"| || style="background:#0FF"|5 || style="background:#0FF"|6 || style="background:#0FF"|7 || style="background:#0FF"|8 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|9 || style="background:gray"| || <ref name="Steinbuch_1962"/><!-- <ref name="Steinbuch-Wagner_1967"/><ref name="Steinbuch-Weber-Heinemann_1974"/> --><ref name="Dokter_1973"/><ref name="Dokter_1975"/> |- | colspan="19"| |- | {{anchor|5121}}colspan="2"|'''5 1 2 1''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:#0FF"|2 || style="background:#0FF"|3 || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:#0FF"|4 || style="background:#0FF"|5 || style="background:#0FF"|6 || style="background:#0FF"|7 || style="background:#0FF"|8 || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:#0FF"|9 || <ref name="Chinal_1973"/> |- | colspan="19"| |- | {{anchor|5311}}colspan="2"|'''5 3 1 1''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:gray"| || style="background:#0FF"|2 || style="background:#0FF"|3 || style="background:#0FF"|4 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|5 || style="background:#0FF"|6 || style="background:gray"| || style="background:#0FF"|7 || style="background:#0FF"|8 || style="background:#0FF"|9 || style="background:gray"| || style="background:gray"| || <ref name="Dokter_1973"/><ref name="Dokter_1975"/> |- | colspan="19"| |- | {{anchor|White}}colspan="2"|'''{{nowrap|White (5 2 1 1)}}''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:gray"| || style="background:#0FF"|2 || style="background:gray"| || style="background:#0FF"|3 || style="background:gray"| || style="background:#0FF"|4 || style="background:#0FF"|5 || style="background:#0FF"|6 || style="background:gray"| || style="background:#0FF"|7 || style="background:gray"| || style="background:#0FF"|8 || style="background:gray"| || style="background:#0FF"|9 || <ref name="White_1953"/><ref name="Kautz_1954"/><ref name="Steinbuch_1962"/><!-- <ref name="Steinbuch-Wagner_1967"/><ref name="Steinbuch-Weber-Heinemann_1974"/> --><ref name="Dokter_1973"/><ref name="Dokter_1975"/> |- | colspan="19"| |- | {{anchor|5211}}colspan="2"|'''5 2 1 1''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:gray"| || style="background:#0FF"|2 || style="background:gray"| || style="background:#0FF"|3 || style="background:gray"| || style="background:#0FF"|4 || style="background:#0FF"|5 || style="background:gray"| || style="background:#0FF"|6 || style="background:gray"| || style="background:#0FF"|7 || style="background:gray"| || style="background:#0FF"|8 || style="background:#0FF"|9 || <ref name="EHub_2015"/> |- | colspan="19"| |- | colspan="2"| || style="background:lightgray"|0 || style="background:lightgray"|1 || style="background:lightgray"|2 || style="background:lightgray"|3 || style="background:lightgray"|4 || style="background:lightgray"|5 || style="background:lightgray"|6 || style="background:lightgray"|7 || style="background:lightgray"|8 || style="background:lightgray"|9 || style="background:lightgray"|10 || style="background:lightgray"|11 || style="background:lightgray"|12 || style="background:lightgray"|13 || style="background:lightgray"|14 || style="background:lightgray"|15 || |- | colspan="19"| |- | {{anchor|Tape}}colspan="2"|'''Magnetic tape''' || style="background:gray"| || style="background:#0FF"|1 || style="background:#0FF"|2 || style="background:#0FF"|3 || style="background:#0FF"|4 || style="background:#0FF"|5 || style="background:#0FF"|6 || style="background:#0FF"|7 || style="background:#0FF"|8 || style="background:#0FF"|9 || style="background:#0FF"|0 || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:gray"| || <ref name="Kämmerer_1969"/> |- | colspan="19"| |- | {{anchor|Paul}}colspan="2"|'''Paul''' || style="background:gray"| || style="background:#0FF"|1 || style="background:#0FF"|3 || style="background:#0FF"|2 || style="background:#0FF"|6 || style="background:#0FF"|7 || style="background:#0FF"|5 || style="background:#0FF"|4 || style="background:gray"| || style="background:#0FF"|0 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|8 || style="background:#0FF"|9 || style="background:gray"| || style="background:gray"| || <ref name="Paul_1995"/> |- | colspan="19"| |- | colspan="2"|'''{{nowrap|[[Gray BCD code|Gray]]}}''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:#0FF"|3 || style="background:#0FF"|2 || style="background:#0FF"|6 || style="background:#0FF" |7 || style="background:#0FF" |5 || style="background:#0FF" |4 || style="background:gray" |15 || style="background:gray"|14 || style="background:gray"|12 || style="background:gray"|13 || style="background:#0FF"|8 || style="background:#0FF"|9 || style="background:gray"|11 || style="background:gray"|10 || <ref name="Gray_1947"/><!-- <ref name="Kautz_1954"/> --><ref name="Steinbuch_1962"/><!-- <ref name="Steinbuch-Wagner_1967"/><ref name="Steinbuch-Weber-Heinemann_1974"/> --><ref name="Kämmerer_1969"/><ref name="Dokter_1973"/><ref name="Dokter_1975"/><ref group="nb" name="Non-BCD"/> |- | colspan="19"| |- | colspan="2"|'''{{nowrap|[[Glixon code|Glixon]]}}''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:#0FF"|3 || style="background:#0FF"|2 || style="background:#0FF"|6 || style="background:#0FF"|7 || style="background:#0FF"|5 || style="background:#0FF"|4 || style="background:#0FF"|9 || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:#0FF"|8 || style="background:gray"| || style="background:gray"| || style="background:gray"| || <ref name="Glixon_1957"/><ref name="Steinbuch_1962"/><!-- <ref name="Steinbuch-Wagner_1967"/><ref name="Steinbuch-Weber-Heinemann_1974"/> --><ref name="Kämmerer_1969"/><ref name="Dokter_1973"/><ref name="Dokter_1975"/> |- | colspan="19"| |- | {{anchor|Ledley}}colspan="2"|'''Ledley''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:#0FF|3 || style="background:#0FF"|2 || style="background:#0FF"|7 || style="background:#0FF"|6 || style="background:#0FF"|4 || style="background:#0FF"|5 || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:#0FF"|8 || style="background:gray"| || style="background:#0FF"|9 || style="background:gray"| || <ref name="Ledley_1960"/> |- | colspan="19"| |- | {{anchor|4311}}colspan="2"|'''4 3 1 1''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:gray"| || style="background:#0FF"|2 || style="background:#0FF"|3 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|5 || style="background:#0FF"|4 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|6 || style="background:#0FF"|7 || style="background:gray"| || style="background:#0FF"|8 || style="background:#0FF"|9 || <ref name="Chinal_1973"/> |- | colspan="19"| |- | {{anchor|LARC}}colspan="2"|'''[[UNIVAC LARC|LARC]]''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:gray"| || style="background:#0FF"|2 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|4 || style="background:#0FF"|3 || style="background:#0FF"|5 || style="background:#0FF"|6 || style="background:gray"| || style="background:#0FF"|7 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|9 || style="background:#0FF"|8 || <ref name="Savard_2018_Decimal"/> |- | colspan="19"| |- | {{anchor|Klar}}colspan="2"|'''Klar''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:gray"| || style="background:#0FF"|2 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|4 || style="background:#0FF"|3 || style="background:#0FF"|9 || style="background:#0FF"|8 || style="background:gray"| || style="background:#0FF"|7 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|5 || style="background:#0FF"|6 || <ref name="Klar_1970"/><ref name="Klar_1989"/> |- | colspan="19"| |- | colspan="2"|'''{{nowrap|[[Petherick code|Petherick]] (RAE)}}''' || style="background:gray"| || style="background:#0FF"|1 || style="background:#0FF"|3 || style="background:#0FF"|2 || style="background:gray"| || style="background:#0FF"|0 || style="background:#0FF"|4 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|8 || style="background:#0FF"|6 || style="background:#0FF"|7 || style="background:gray"| || style="background:#0FF"|9 || style="background:#0FF"|5 || style="background:gray"| || <ref name="Petherick_1953"/><ref name="Petherick-Hopkins_1958"/><ref group="nb" name="Petherick_RAE"/> |- | colspan="19"| |- | colspan="2"|'''{{nowrap|[[O'Brien code I|O'Brien I]] (Watts)}}''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:#0FF"|3 || style="background:#0FF"|2 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|4 || style="background:gray"| || style="background:#0FF"|9 || style="background:#0FF"|8 || style="background:#0FF"|6 || style="background:#0FF"|7 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|5 || style="background:gray"| || <ref name="O'Brien_1955"/><ref name="Steinbuch_1962"/><!-- <ref name="Steinbuch-Wagner_1967"/><ref name="Steinbuch-Weber-Heinemann_1974"/> --><ref name="Dokter_1973"/><ref name="Dokter_1975"/><ref group="nb" name="O'Brien-I_WRD"/> |- | colspan="19"| |- | {{anchor|5-cyclic}}colspan="2"|'''5-cyclic''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:#0FF|3 || style="background:#0FF"|2 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|4 || style="background:gray"| || style="background:#0FF"|5 || style="background:#0FF"|6 || style="background:#0FF"|8 || style="background:#0FF"|7 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|9 || style="background:gray"| || <ref name="Ledley_1960"/> |- | colspan="19"| |- | colspan="2"|'''{{nowrap|[[Tompkins code I|Tompkins I]]}}''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:#0FF"|3 || style="background:#0FF"|2 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|4 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|9 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|8 || style="background:#0FF"|7 || style="background:#0FF"|5 || style="background:#0FF"|6 || <ref name="Tompkins_1956"/><ref name="Steinbuch_1962"/><!-- <ref name="Steinbuch-Wagner_1967"/><ref name="Steinbuch-Weber-Heinemann_1974"/> --><ref name="Dokter_1973"/><ref name="Dokter_1975"/> |- | colspan="19"| |- | {{anchor|Lippel}}colspan="2"|'''Lippel''' || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:#0FF"|2 || style="background:#0FF"|3 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|4 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|9 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|8 || style="background:#0FF"|7 || style="background:#0FF"|6 || style="background:#0FF"|5 || <ref name="Lippel_1955"/><ref name="Susskind_1958"/><ref name="Steinbuch_1962"/><!-- <ref name="Steinbuch-Wagner_1967"/><ref name="Steinbuch-Weber-Heinemann_1974"/> --> |- | colspan="19"| |- | colspan="2"|'''{{nowrap|[[O'Brien code II|O'Brien II]]}}''' || style="background:gray"| || style="background:#0FF"|0 || style="background:#0FF"|2 || style="background:#0FF"|1 || style="background:#0FF"|4 || style="background:gray"| || style="background:#0FF"|3 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|9 || style="background:#0FF"|7 || style="background:#0FF"|8 || style="background:#0FF"|5 || style="background:gray"| || style="background:#0FF"|6 || style="background:gray"| || <ref name="O'Brien_1955"/><ref name="Steinbuch_1962"/><!-- <ref name="Steinbuch-Wagner_1967"/><ref name="Steinbuch-Weber-Heinemann_1974"/> --><ref name="Dokter_1973"/><ref name="Dokter_1975"/> |- | colspan="19"| |- | colspan="2"|'''{{nowrap|[[Tompkins code II|Tompkins II]]}}''' || style="background:gray"| || style="background:gray"| || style="background:#0FF"|0 || style="background:#0FF"|1 || style="background:#0FF"|4 || style="background:#0FF"|3 || style="background:gray"| || style="background:#0FF"|2 || style="background:gray"| || style="background:#0FF"|7 || style="background:#0FF"|9 || style="background:#0FF"|8 || style="background:#0FF"|5 || style="background:#0FF"|6 || style="background:gray"| || style="background:gray"| || <ref name="Tompkins_1956"/><ref name="Steinbuch_1962"/><!-- <ref name="Steinbuch-Wagner_1967"/><ref name="Steinbuch-Weber-Heinemann_1974"/> --><ref name="Dokter_1973"/><ref name="Dokter_1975"/> |- | colspan="19"| |- | colspan="2"|'''{{nowrap|[[Excess-3 Gray code|Excess-3 Gray]]}}''' || style="background:gray"|-3 || style="background:gray"|-2 || style="background:#0FF"|0 || style="background:gray"|-1 || style="background:#0FF"|4 || style="background:#0FF"|3 || style="background:#0FF"|1 || style="background:#0FF"|2 || style="background:gray"|12 || style="background:gray"|11 || style="background:#0FF"|9 || style="background:gray"|10 || style="background:#0FF"|5 || style="background:#0FF"|6 || style="background:#0FF"|8 || style="background:#0FF"|7 || <ref name="Dokter_1973"/><ref name="Dokter_1975"/><ref name="MIL_1991"/><ref group="nb" name="Gray_Stibitz"/><ref group="nb" name="Non-BCD"/> |- | colspan="19"| |- | {{anchor|63−2−1}}colspan="2"|'''6 3 −2 −1 (I)''' || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:#0FF"|3 || style="background:#0FF"|2 || style="background:#0FF"|1 || style="background:#0FF"|0 || style="background:gray"| || style="background:#0FF"|5 || style="background:#0FF"|4 || style="background:#0FF"|8 || style="background:#0FF"|9 || style="background:gray"| || style="background:#0FF"|7 || style="background:#0FF"|6 || <ref name="Savard_2018_Decimal"/><ref name="Yuen_1977"/> |- | colspan="19"| |- | {{anchor|63−2−1 II}}colspan="2"|'''6 3 −2 −1 (II)''' || style="background:#0FF"|0 || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:#0FF"|3 || style="background:#0FF"|2 || style="background:#0FF"|1 || style="background:gray"| || style="background:#0FF"|6 || style="background:#0FF"|5 || style="background:#0FF"|4 || style="background:gray"| || style="background:#0FF"|9 || style="background:#0FF"|8 || style="background:#0FF"|7 || style="background:gray"| || <ref name="Savard_2018_Decimal"/><ref name="Yuen_1977"/> |- | colspan="19"| |- | {{anchor|84−2−1}}colspan="2"|'''8 4 −2 −1''' || style="background:#0FF"|0 || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:#0FF"|4 || style="background:#0FF"|3 || style="background:#0FF"|2 || style="background:#0FF"|1 || style="background:#0FF"|8 || style="background:#0FF"|7 || style="background:#0FF"|6 || style="background:#0FF"|5 || style="background:gray"| || style="background:gray"| || style="background:gray"| || style="background:#0FF"|9 || <ref name="Savard_2018_Decimal"/> |- | colspan="19"| |- | {{anchor|Lucal}}colspan="2"|'''[[Lucal code|Lucal]]''' || style="background:#0FF"|0 || style="background:gray"|15 || style="background:gray"|14 || style="background:#0FF"|1 || style="background:gray"|12 || style="background:#0FF"|3 || style="background:#0FF"|2 || style="background:gray"|13 || style="background:#0FF"|8 || style="background:#0FF"|7 || style="background:#0FF"|6 || style="background:#0FF"|9 || style="background:#0FF"|4 || style="background:gray"|11 || style="background:gray"|10 || style="background:#0FF"|5 || <ref name="Lucal_1959"/> |- | colspan="19"| |- | {{anchor|Kautz}}colspan="2"|'''Kautz I''' || style="background:#0FF"|0 || style="background:gray"| || style="background:gray"| || style="background:#0FF"|2 || style="background:gray"| || style="background:#0FF"|5 || style="background:#0FF"|1 || style="background:#0FF"|3 || style="background:gray"| || style="background:#0FF"|7 || style="background:#0FF"|9 || style="background:gray"| || style="background:#0FF"|8 || style="background:#0FF"|6 || style="background:gray"| || style="background:#0FF"|4 || <ref name="Kautz_1954"/> |- | colspan="19"| |- | {{anchor|Kautz II}}colspan="2"|'''Kautz II''' || style="background:gray"| || style="background:#0FF"|9 || style="background:#0FF"|4 || style="background:gray"| || style="background:#0FF"|1 || style="background:gray"| || style="background:#0FF"|3 || style="background:#0FF"|2 || style="background:#0FF"|8 || style="background:gray"| || style="background:#0FF"|6 || style="background:#0FF"|7 || style="background:gray"| || style="background:#0FF"|0 || style="background:#0FF"|5 || style="background:gray"| || <ref name="Kautz_1954"/><ref name="Steinbuch_1962"/><!-- <ref name="Steinbuch-Wagner_1967"/><ref name="Steinbuch-Weber-Heinemann_1974"/> --> |- | colspan="19"| |- | {{anchor|Susskind}}colspan="2"|'''Susskind I''' || style="background:gray"| || style="background:#0FF"|0 || style="background:gray"| || style="background:#0FF"|1 || style="background:gray"| || style="background:#0FF"|4 || style="background:#0FF"|3 || style="background:#0FF"|2 || style="background:gray"| || style="background:#0FF"|9 || style="background:gray"| || style="background:#0FF"|8 || style="background:#0FF"|5 || style="background:gray"| || style="background:#0FF"|6 || style="background:#0FF"|7 || <ref name="Susskind_1958"/> |- | colspan="19"| |- | {{anchor|Susskind II}}colspan="2"|'''Susskind II''' || style="background:gray"| || style="background:#0FF"|0 || style="background:gray"| || style="background:#0FF"|1 || style="background:gray"| || style="background:#0FF"|9 || style="background:gray"| || style="background:#0FF"|8 || style="background:#0FF"|4 || style="background:gray"| || style="background:#0FF"|3 || style="background:#0FF"|2 || style="background:#0FF"|5 || style="background:gray"| || style="background:#0FF"|6 || style="background:#0FF"|7 || <ref name="Susskind_1958"/> |- | colspan="19"| |- | colspan="2"| || style="background:lightgray"|0 || style="background:lightgray"|1 || style="background:lightgray"|2 || style="background:lightgray"|3 || style="background:lightgray"|4 || style="background:lightgray"|5 || style="background:lightgray"|6 || style="background:lightgray"|7 || style="background:lightgray"|8 || style="background:lightgray"|9 || style="background:lightgray"|10 || style="background:lightgray"|11 || style="background:lightgray"|12 || style="background:lightgray"|13 || style="background:lightgray"|14 || style="background:lightgray"|15 || |} The following table represents [[decimal]] digits from 0 to 9 in various BCD encoding systems. In the headers, the "<code>8{{thinsp}}4{{thinsp}}2{{thinsp}}1</code>" indicates the weight of each bit. In the fifth column ("BCD 8{{thinsp}}4{{thinsp}}−2{{thinsp}}−1"), two of the weights are negative. Both ASCII and EBCDIC character codes for the digits, which are examples of zoned BCD, are also shown. {| class="wikitable" style="margin:auto;" |- ! style="background:#e0e0e0;"| <br />Digit ! style="background:#e0e0e0;"| BCD<br />8{{thinsp}}4{{thinsp}}2{{thinsp}}1 ! style="background:#e0e0e0;"| [[George Stibitz|Stibitz]] code or [[Excess-3]] ! style="background:#e0e0e0;"| [[Aiken-Code]] or BCD<br />2{{thinsp}}4{{thinsp}}2{{thinsp}}1 ! style="background:#e0e0e0;"| BCD<br />8{{thinsp}}4{{thinsp}}−2{{thinsp}}−1 ! style="background:#e0e0e0;"| {{nowrap| [[IBM 702]], }} {{nowrap| [[IBM 705]], }} {{nowrap| [[IBM 7080]], }} {{nowrap| [[IBM 1401]] }}<br /> 8{{thinsp}}4{{thinsp}}2{{thinsp}}1 ! style="background:#e0e0e0;"| [[ASCII]] <br />0000 8421 ! style="background:#e0e0e0;"| [[EBCDIC]] <br />0000 8421 |- style="text-align:center;" ! style="background:#f0f0f0;"|0 | 0000 | 0011 | 0000 | 0000 | 1010 | 0011 0000 | 1111 0000 |- style="text-align:center;" ! style="background:#f0f0f0;"|1 | 0001 | 0100 | 0001 | 0111 | 0001 | 0011 0001 | 1111 0001 |- style="text-align:center;" ! style="background:#f0f0f0;"|2 | 0010 | 0101 | 0010 | 0110 | 0010 | 0011 0010 | 1111 0010 |- style="text-align:center;" ! style="background:#f0f0f0;"|3 | 0011 | 0110 | 0011 | 0101 | 0011 | 0011 0011 | 1111 0011 |- style="text-align:center;" ! style="background:#f0f0f0;"|4 | 0100 | 0111 | 0100 | 0100 | 0100 | 0011 0100 | 1111 0100 |- style="text-align:center;" ! style="background:#f0f0f0;"|5 | 0101 | 1000 | 1011 | 1011 | 0101 | 0011 0101 | 1111 0101 |- style="text-align:center;" ! style="background:#f0f0f0;"|6 | 0110 | 1001 | 1100 | 1010 | 0110 | 0011 0110 | 1111 0110 |- style="text-align:center;" ! style="background:#f0f0f0;"|7 | 0111 | 1010 | 1101 | 1001 | 0111 | 0011 0111 | 1111 0111 |- style="text-align:center;" ! style="background:#f0f0f0;"|8 | 1000 | 1011 | 1110 | 1000 | 1000 | 0011 1000 | 1111 1000 |- style="text-align:center;" ! style="background:#f0f0f0;"|9 | 1001 | 1100 | 1111 | 1111 | 1001 | 0011 1001 | 1111 1001 |} As most computers deal with data in 8-bit [[byte]]s, it is possible to use one of the following methods to encode a BCD number: * '''Unpacked''': Each decimal digit is encoded into one byte, with four bits representing the number and the remaining bits having no significance. * '''Packed''': Two decimal digits are encoded into a single byte, with one digit in the least significant [[nibble]] ([[Bit numbering#Most- vs least-significant bit first|bits 0 through 3]]) and the other numeral in the most significant nibble (bits 4 through 7).<ref group="nb" name="Packed_chars"/> As an example, encoding the decimal number <code>'''91'''</code> using unpacked BCD results in the following binary pattern of two bytes: Decimal: 9 1 Binary : 0000 1001 0000 0001 In packed BCD, the same number would fit into a single byte: Decimal: 9 1 Binary : 1001 0001 Hence the numerical range for one unpacked BCD byte is zero through nine inclusive, whereas the range for one packed BCD byte is zero through ninety-nine inclusive. To represent numbers larger than the range of a single byte any number of contiguous bytes may be used. For example, to represent the decimal number <code>'''12345'''</code> in packed BCD, using [[big-endian]] format, a program would encode as follows: Decimal: 0 1 2 3 4 5 Binary : 0000 0001 0010 0011 0100 0101 Here, the most significant nibble of the most significant byte has been encoded as zero, so the number is stored as <code>'''012345'''</code> (but formatting routines might replace or remove leading zeros). Packed BCD is more efficient in storage usage than unpacked BCD; encoding the same number (with the leading zero) in unpacked format would consume twice the storage. [[Logical shift|Shifting]] and [[mask (computing)|masking]] operations are used to pack or unpack a packed BCD digit. Other [[bitwise operation]]s are used to convert a numeral to its equivalent bit pattern or reverse the process.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Binary-coded decimal
(section)
Add topic