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
Two-out-of-five code
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!
{{Short description|Error-detection code for decimal digits}} {{Use dmy dates|date=May 2019|cs1-dates=y}} [[Image:Barcode2of5example.svg|thumb| 2 of 5 barcode (non-interleaved)]] [[Image:Correios CEP 22011-080 - Codigo de Barras - PU1JFC.jpg|thumb| [[POSTNET]] barcode]] A '''two-out-of-five code''' is a [[constant-weight code]] that provides exactly ten possible combinations of two bits, and is thus used for representing the [[decimal digit]]s using five [[bit]]s.<ref name="MIL_1991"/> Each bit is assigned a weight, such that the set bits sum to the desired value, with an exception for zero. According to [[Federal Standard 1037C]]: * each decimal [[numerical digit|digit]] is represented by a binary numeral consisting of five bits of which two are of one kind, called ''ones'', and three are of the other kind, called ''zeros'', and * the usual weights assigned to the bit positions are 0-1-2-3-6. However, in this scheme, [[0 (number)|zero]] is encoded as binary ''01100''; strictly speaking the 0-1-2-3-6 previously claimed is just a [[mnemonic]] device.<ref>{{FS1037C}}</ref> The weights give a unique encoding for most digits, but allow two encodings for 3: 0+3 or 10010 and 1+2 or 01100. The former is used to encode the digit 3, and the latter is used to represent the otherwise unrepresentable zero. The [[IBM 7070]], [[IBM 7072]], and [[IBM 7074]] computers used this code to represent each of the ten decimal digits in a machine word, although they numbered the bit positions 0-1-2-3-4, rather than with weights. Each word also had a sign flag, encoded using a two-out-of-three code, that could be '''A''' Alphanumeric, '''โ''' Minus, or '''+''' Plus. When copied to a digit, the three bits were placed in bit positions 0-3-4. (Thus producing the numeric values 3, 6 and 9, respectively.) A variant is the [[United States Postal Service]] [[POSTNET]] [[barcode]], used to represent the [[ZIP Code]] for automated mail sorting and routing equipment. This uses two tall bars as ones and three short bars as zeros. Here, the weights assigned to the bit positions are 7-4-2-1-0. Again, zero is encoded specially, using the 7+4 combination (binary 11000) that would naturally encode 11. This method was also used in North American telephone [[multi-frequency]] and [[crossbar switch]]ing systems.<ref>{{cite web|url=http://simplethinking.com/photo/phone/vintage/xbr%20relays.shtml|archive-url=https://web.archive.org/web/20060316134506/http://simplethinking.com/photo/phone/vintage/xbr%20relays.shtml|archive-date=2006-03-16|title=Vintage Telephone Equipment Museum โ XBR #5 MTF Relay Equip|website=SimpleThinking.com}}</ref> The USPS [[Postal Alpha Numeric Encoding Technique]] (PLANET) uses the same weights, but with the opposite bar-height convention. The [[Code 39]] barcode uses weights 1-2-4-7-0 (i.e. [[Least significant bit|LSB]] first, [[Parity bit]] last) for the widths of its bars, but it also encodes two bits of extra information in the spacing between bars. The || ||| spacing is used for digits. The following table represents [[decimal]] digits from 0 to 9 in various two-out-of-five code systems: {| class="wikitable" style="text-align: center;" |- ! Digit ! Telecommunication <br/> 01236 ! POSTNET <br/><div align=left>74210</div> ! PLANET ! Code39 <br/> bar widths <br> 12470 |- ! 1 | 11000 | 00011 [[Image:POSTNET 1.svg]] | '''โโโโปโป''' | โฎ {{pipe}} {{pipe}} {{pipe}} โฎ |- ! 2 | 10100 | 00101 [[Image:POSTNET 2.svg]] | '''โโโปโโป''' | {{pipe}} โฎ {{pipe}} {{pipe}} โฎ |- ! 3 | 10010 | 00110 [[Image:POSTNET 3.svg]] | '''โโโปโปโ''' | โฎ โฎ {{pipe}} {{pipe}} {{pipe}} |- ! 4 | 01010 | 01001 [[Image:POSTNET 4.svg]] | '''โโปโโโป''' | {{pipe}} {{pipe}} โฎ {{pipe}} โฎ |- ! 5 | 00110 | 01010 [[Image:POSTNET 5.svg]] | '''โโปโโปโ''' | โฎ {{pipe}} โฎ {{pipe}} {{pipe}} |- ! 6 | 10001 | 01100 [[Image:POSTNET 6.svg]] | '''โโปโปโโ''' | {{pipe}} โฎ โฎ {{pipe}} {{pipe}} |- ! 7 | 01001 | 10001 [[Image:POSTNET 7.svg]] | '''โปโโโโป''' | {{pipe}} {{pipe}} {{pipe}} โฎ โฎ |- ! 8 | 00101 | 10010 [[Image:POSTNET 8.svg]] | '''โปโโโปโ''' | โฎ {{pipe}} {{pipe}} โฎ {{pipe}} |- ! 9 | 00011 | 10100 [[Image:POSTNET 9.svg]] | '''โปโโปโโ''' | {{pipe}} โฎ {{pipe}} โฎ {{pipe}} |- ! 0 | 01100 | 11000 [[Image:POSTNET 0.svg]] | '''โปโปโโโ''' | {{pipe}} {{pipe}} โฎ โฎ {{pipe}} |- |colspan=5| |- ! A | 1โโ10 !rowspan=3 colspan=3| IBM 707x<br/>Sign flags |- ! โ | 1โโ01 |- ! + | 0โโ11 |- ! Digit ! 01234 <br/> IBM 707x !colspan=3| |} The requirement that exactly two bits be set is strictly stronger than a [[parity check]]; like all [[constant-weight code]]s, a two-out-of-five code can detect not only any single-bit error, but any [[unidirectional error]] -- cases in which all the individual bit errors are of a single type (all 0โ1 or all 1โ0). ==See also== * [[Bi-quinary coded decimal]] ==References== {{reflist|refs= <ref name="MIL_1991">{{cite book |title=Military Handbook: Encoders - Shaft Angle To Digital |publisher=[[United States Department of Defense]] |id=MIL-HDBK-231A |date=1991-09-30 |url=http://everyspec.com/MIL-HDBK/MIL-HDBK-0200-0299/download.php?spec=MIL_HDBK_231A.1809.pdf |access-date=2020-07-25 |url-status=live |archive-url=https://web.archive.org/web/20200725051128/http://everyspec.com/MIL-HDBK/MIL-HDBK-0200-0299/download.php?spec=MIL_HDBK_231A.1809.pdf |archive-date=2020-07-25}} (NB. Supersedes MIL-HDBK-231(AS) (1970-07-01).)</ref> }} {{Barcodes}} [[Category:Barcodes]] [[Category:Computer arithmetic]] [[Category:Telephony signals]]
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)
Templates used on this page:
Template:Barcodes
(
edit
)
Template:Cite web
(
edit
)
Template:FS1037C
(
edit
)
Template:Pipe
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Use dmy dates
(
edit
)
Search
Search
Editing
Two-out-of-five code
Add topic