Offset binary#Excess-25

{{Short description|Method for signed number representation}}

{{About|biased representations in general|the excess-3 representation|Shifted binary (code)|binary shifting|Bit shifting}}

{{Use dmy dates|date=May 2019|cs1-dates=y}}

Offset binary, also referred to as excess-K, excess-N, excess-e, excess code or biased representation, is a method for signed number representation where a signed number n is represented by the bit pattern corresponding to the unsigned number n+K, K being the biasing value or offset. There is no standard for offset binary, but most often the K for an n-bit binary word is K = 2n−1 (for example, the offset for a four-digit binary number would be 23=8). This has the consequence that the minimal negative value is represented by all-zeros, the "zero" value is represented by a 1 in the most significant bit and zero in all other bits, and the maximal positive value is represented by all-ones (conveniently, this is the same as using two's complement but with the most significant bit inverted). It also has the consequence that in a logical comparison operation, one gets the same result as with a true form numerical comparison operation, whereas, in two's complement notation a logical comparison will agree with true form numerical comparison operation if and only if the numbers being compared have the same sign. Otherwise the sense of the comparison will be inverted, with all negative values being taken as being larger than all positive values.

{{anchor|Excess-1}}The 5-bit Baudot code used in early synchronous multiplexing telegraphs can be seen as an offset-1 (excess-1) reflected binary (Gray) code.

{{anchor|Excess-64}}One historically prominent example of offset-64 (excess-64) notation was in the floating point (exponential) notation in the IBM System/360 and System/370 generations of computers. The "characteristic" (exponent) took the form of a seven-bit excess-64 number (The high-order bit of the same byte contained the sign of the significand).

{{anchor|Excess-129}}The 8-bit exponent in Microsoft Binary Format, a floating point format used in various programming languages (in particular BASIC) in the 1970s and 1980s, was encoded using an offset-129 notation (excess-129).

{{anchor|Excess-15|Excess-127|Excess-1023|Excess-16383}}The IEEE Standard for Floating-Point Arithmetic (IEEE 754) uses offset notation for the exponent part in each of its various formats of precision. Unusually however, instead of using "excess 2n−1" it uses "excess 2n−1 − 1" (i.e. excess-15, excess-127, excess-1023, excess-16383) which means that inverting the leading (high-order) bit of the exponent will not convert the exponent to correct two's complement notation.

Offset binary is often used in digital signal processing (DSP). Most analog to digital (A/D) and digital to analog (D/A) chips are unipolar, which means that they cannot handle bipolar signals (signals with both positive and negative values). A simple solution to this is to bias the analog signals with a DC offset equal to half of the A/D and D/A converter's range. The resulting digital data then ends up being in offset binary format.

Most standard computer CPU chips cannot handle the offset binary format directly{{citation needed|reason=This claim is not cited not supported in the paragraph|date=January 2022}}. CPU chips typically can only handle signed and unsigned integers, and floating point value formats. Offset binary values can be handled in several ways by these CPU chips. The data may just be treated as unsigned integers, requiring the programmer to deal with the zero offset in software. The data may also be converted to signed integer format (which the CPU can handle natively) by simply subtracting the zero offset. As a consequence of the most common offset for an n-bit word being 2n−1, which implies that the first bit is inverted relative to two's complement, there is no need for a separate subtraction step, but one simply can invert the first bit. This sometimes is a useful simplification in hardware, and can be convenient in software as well.

Table of offset binary for four bits, with two's complement for comparison:

class="wikitable" border="1"
Decimal

! Offset binary,
K = 8

! Two's
complement

7

| 1111

| 0111

6

| 1110

| 0110

5

| 1101

| 0101

4

| 1100

| 0100

3

| 1011

| 0011

2

| 1010

| 0010

1

| 1001

| 0001

0

| 1000

| 0000

−1

| 0111

| 1111

−2

| 0110

| 1110

−3

| 0101

| 1101

−4

| 0100

| 1100

−5

| 0011

| 1011

−6

| 0010

| 1010

−7

| 0001

| 1001

−8

| 0000

| 1000

Offset binary may be converted into two's complement by inverting the most significant bit. For example, with 8-bit values, the offset binary value may be XORed with 0x80 in order to convert to two's complement. In specialised hardware it may be simpler to accept the bit as it stands, but to apply its value in inverted significance.

{{anchor|Nuding|Diamond}}Related codes

{{Missing information|section|these tables|date=January 2022}}

:z = \frac{1}{q}\left[\left(\sum_{i=1}^n p_i \times b_i\right) - k\right]

class="wikitable"

|+ Code comparison

rowspan=2 | Code

! rowspan=2 | Type

! colspan=3 | Parameters

! rowspan=2 | Weights

! rowspan=2 | Distance

! rowspan=2 | Checking

! rowspan=2 | Complement

! rowspan=2 | Groups of 5

! rowspan=2 | Simple addition

Offset, k

! Width, n

! Factor, q

8421 code

| n

| 0

| 4

| 1

| 8 4 2 1

| 1–4

| No

| No

| No

| No

Nuding code

| 3n + 2

| 2

| 5

| 3

| {{n/a}}

| 2–5

| Yes

| 9

| Yes

| Yes

Stibitz code

| n + 3

| 3

| 4

| 1

| 8  4 {{overline|−2}} {{overline|−1}}

| 1–4

| No

| 9

| Yes

| Yes

Diamond code

| 27n + 6

| 6

| 8

| 27

| {{n/a}}

| 3–8

| Yes

| 9

| Yes

| Yes

| 25n + 15

| 15

| 8

| 25

| {{n/a}}

| 3+

| Yes

| Yes

| ?

| Yes

| 23n + 24

| 24

| 8

| 23

| {{n/a}}

| 3+

| Yes

| Yes

| ?

| Yes

| 19n + 42

| 42

| 8

| 19

| {{n/a}}

| 3–8

| Yes

| 9

| Yes

| Yes

{| class="wikitable" style="text-align:center;"

|+ Decimal

! style="background:lightgray"| 

0
1
2
3
4
style="background:lightgray"|5
style="background:lightgray"|6
style="background:lightgray"|7
style="background:lightgray"|8
style="background:lightgray"|9

|

class="wikitable" style="text-align:center;"

|+ 8421

! style="background:lightgray"|4 !! style="background:lightgray"|3 !! style="background:lightgray"|2 !! style="background:lightgray"|1

0000
000style="background:#0FF"|1
00style="background:#0FF"|10
00style="background:#0FF"|1style="background:#0FF"|1
0style="background:#0FF"|100
0style="background:#0FF"|10style="background:#0FF"|1
0style="background:#0FF"|1style="background:#0FF"|10
0style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|1
style="background:#0FF"|1000
style="background:#0FF"|100style="background:#0FF"|1

|

|

|

|

|

class="wikitable" style="text-align:center;"

|+ Stibitz

! style="background:lightgray" | 4

! style="background:lightgray" | 3

! style="background:lightgray" | 2

! style="background:lightgray" | 1

00style="background:#0FF"|1style="background:#0FF"|1
0style="background:#0FF"|100
0style="background:#0FF"|10style="background:#0FF"|1
0style="background:#0FF"|1style="background:#0FF"|10
0style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|1
style="background:#0FF"|1000
style="background:#0FF"|100style="background:#0FF"|1
style="background:#0FF"|10style="background:#0FF"|10
style="background:#0FF"|10style="background:#0FF"|1style="background:#0FF"|1
style="background:#0FF"|1style="background:#0FF"|100

|

class="wikitable" style="text-align:center;"

|+ Nuding

! style="background:lightgray"|5

! style="background:lightgray"|4

! style="background:lightgray"|3

! style="background:lightgray"|2

! style="background:lightgray"|1

000style="background:#0FF"|10
00style="background:#0FF"|10style="background:#0FF"|1
0style="background:#0FF"|1000
0style="background:#0FF"|10style="background:#0FF"|1style="background:#0FF"|1
0style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|10
style="background:#0FF"|1000style="background:#0FF"|1
style="background:#0FF"|10style="background:#0FF"|100
style="background:#0FF"|10style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|1
style="background:#0FF"|1style="background:#0FF"|10style="background:#0FF"|10
style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|10style="background:#0FF"|1

|

class="wikitable" style="text-align:center;"

|+ Diamond

! style="background:lightgray"|8 !! style="background:lightgray"|7 !! style="background:lightgray"|6 !! style="background:lightgray"|5 !! style="background:lightgray"|4 !! style="background:lightgray"|3 !! style="background:lightgray"|2 !! style="background:lightgray"|1

00000style="background:#0FF"|1style="background:#0FF"|10
00style="background:#0FF"|10000style="background:#0FF"|1
00style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|100
0style="background:#0FF"|10style="background:#0FF"|10style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|1
0style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|100style="background:#0FF"|10
style="background:#0FF"|1000style="background:#0FF"|1style="background:#0FF"|10style="background:#0FF"|1
style="background:#0FF"|10style="background:#0FF"|10style="background:#0FF"|1000
style="background:#0FF"|1style="background:#0FF"|10000style="background:#0FF"|1style="background:#0FF"|1
style="background:#0FF"|1style="background:#0FF"|10style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|10
style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|100style="background:#0FF"|1

|

class="wikitable" style="text-align:center;"

|+ 19n + 42

! style="background:lightgray"|8 !! style="background:lightgray"|7 !! style="background:lightgray"|6 !! style="background:lightgray"|5 !! style="background:lightgray"|4 !! style="background:lightgray"|3 !! style="background:lightgray"|2 !! style="background:lightgray"|1

00style="background:#0FF"|10style="background:#0FF"|10style="background:#0FF"|10
00style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|10style="background:#0FF"|1
0style="background:#0FF"|10style="background:#0FF"|10000
0style="background:#0FF"|1style="background:#0FF"|1000style="background:#0FF"|1style="background:#0FF"|1
0style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|10style="background:#0FF"|1style="background:#0FF"|10
style="background:#0FF"|1000style="background:#0FF"|100style="background:#0FF"|1
style="background:#0FF"|100style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|100
style="background:#0FF"|10style="background:#0FF"|10style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|1style="background:#0FF"|1
style="background:#0FF"|1style="background:#0FF"|10000style="background:#0FF"|10
style="background:#0FF"|1style="background:#0FF"|10style="background:#0FF"|10style="background:#0FF"|10style="background:#0FF"|1

|

|}

See also

References

{{Reflist|refs=

{{cite book |author-first1=Angela |author-last1=Chang |author-first2=Yen |author-last2=Chen |author-first3=Patrice |author-last3=Delmas |title=COMPSCI 210S1T 2006 |chapter=2.5.2: Data Representation: Offset binary representation (Excess-K) |date=2006-03-07 |publisher=Department of Computer Science, The University of Auckland, NZ |url=http://www.cs.auckland.ac.nz/~patrice/210-2006/210%20LN04_2.pdf |page=18 |access-date=2016-02-04}}

{{cite book |title=Signal Processing Handbook |editor-first=Chi-hau |editor-last=Chen |publisher=Marcel Dekker, Inc./CRC Press |author=((Electrical and Computer Science Department, Southeastern Massachusetts University, North Dartmouth, MA, USA)) |location=New York, USA |date=1988 |isbn=0-8247-7956-8 |url=https://books.google.com/books?id=10Pi0MRbaOYC |access-date=2016-02-04}}

IBM System/360 Principles of Operation Form A22-6821. Various editions available on the WWW.{{pn|date=January 2020}}

{{cite web |title=Data Conversion Binary Code Formats |publisher=Intersil Corporation |publication-date=2000 |date=May 1997 |id=AN9657.1 |url=http://www.intersil.com/data/an/an9657.pdf |access-date=2016-02-04}}

{{cite book |title=Digital Electronics |author-first1=Folkert |author-last1=Dokter |author-first2=Jürgen |author-last2=Steinhauer |date=1973-06-18 |series=Philips Technical Library (PTL) / Macmillan Education |publisher=The Macmillan Press Ltd. / N. V. Philips' Gloeilampenfabrieken |edition=Reprint of 1st English |location=Eindhoven, Netherlands |sbn=333-13360-9 |isbn=978-1-349-01419-4 |doi=10.1007/978-1-349-01417-0 |page=44 |url=https://books.google.com/books?id=hlRdDwAAQBAJ |access-date=2018-07-01 }} (270 pages) (NB. This is based on a translation of volume I of the two-volume German edition.)

{{cite book |author-first1=Folkert |author-last1=Dokter |author-first2=Jürgen |author-last2=Steinhauer |title=Digitale Elektronik in der Meßtechnik und Datenverarbeitung: Theoretische Grundlagen und Schaltungstechnik |chapter=2.4.4.4. Exzeß-e-Kodes |language=de |series=Philips Fachbücher |publisher=Deutsche Philips GmbH |location=Hamburg, Germany |volume=I |date=1975 |orig-year=1969 |edition=improved and extended 5th |isbn=3-87145-272-6 |pages=51, 53–54}} (xii+327+3 pages) (NB. The German edition of volume I was published in 1969, 1971, two editions in 1972, and 1975. Volume II was published in 1970, 1972, 1973, and 1975.)

{{cite book |title=Elektronik: Digitale Schaltungen und Systeme |chapter=10.5.3.5 Excess-e-Code |language=de |author-first=Bodo |author-last=Morgenstern |date=January 1997 |orig-year=July 1992 |edition=revised 2nd |volume=3 |series=Studium Technik |publisher=Friedrich Vieweg & Sohn Verlagsgesellschaft mbH |isbn=978-3-528-13366-5 |doi=10.1007/978-3-322-85053-9 |pages=120–121 |chapter-url=https://books.google.com/books?id=VcmeBgAAQBAJ&pg=PA120 |access-date=2020-05-26 }} (xviii+393 pages)

{{cite web |title=Complex Computer |author-first=George Robert |author-last=Stibitz |author-link=George Robert Stibitz |id=Patent US2668661A |orig-year=1941-04-19 |date=1954-02-09 |url=https://patents.google.com/patent/US2668661?oq=US2668661 |access-date=2020-05-24 }} [https://web.archive.org/web/20200523235356/https://patentimages.storage.googleapis.com/60/dc/f7/69cd9496a44f6d/US2668661.pdf] (102 pages)

{{cite journal |title=Ein Sicherheitscode für Fernschreibgeräte, die zur Ein- und Ausgabe an elektronischen Rechenmaschine verwendet werden |author-first=Erich |author-last=Nuding |language=de |journal=Zeitschrift für Angewandte Mathematik und Mechanik |series=Kleine Mitteilungen |volume=39 |issue=5–6 |date=1959-01-01 |doi=10.1002/zamm.19590390511 |page=429 |bibcode= 1959ZaMM...39..249N|url=https://onlinelibrary.wiley.com/doi/abs/10.1002/zamm.19590390511}} (1 page)

{{cite journal |title=Checking Codes for Digital Computers |author-first=Joseph M. |author-last=Diamond |series=Correspondence |journal=Proceedings of the IRE |location=New York, USA |issn=0096-8390 |eissn=2162-6634 |volume=43 |issue=4 |date=April 1955 |orig-year=1954-11-12 |pages=483–490 [487–488] |doi=10.1109/JRPROC.1955.277858 |url=https://ieeexplore.ieee.org/document/4055437 |access-date=2020-05-26 |url-status=live |archive-url=https://web.archive.org/web/20200526225857/https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4055437 |archive-date=2020-05-26}} (2 pages) (NB. The results discussed in this report are based on an earlier study carried out by Joseph M. Diamond and Morris Plotkin at Moore School of Engineering, University of Pennsylvania, in 1950–1951, on contract with the Burroughs Adding Machine Co.)

{{cite journal |title=Error Detecting and Correcting Binary Codes for Arithmetic Operations |author-first=David T. |author-last=Brown |date=September 1960 |journal=IRE Transactions on Electronic Computers |volume=EC-9 |issue=3 |issn=0367-9950 |doi=10.1109/TEC.1960.5219855 |s2cid=28263032 |pages=333–337}}

{{cite journal |title=Binary Codes with Specified Minimum Distance |author-first=Morris |author-last=Plotkin |author-link=Morris Plotkin |date=September 1960 |journal=IRE Transactions on Information Theory |volume=IT-6 |issue=4 |issn=0096-1000 |eissn=2168-2712 |doi=10.1109/TIT.1960.1057584 |s2cid=40300278 |pages=445–450}} (NB. Also published as Research Division Report 51-20 of University of Pennsylvania in January 1951.)

{{cite book |title=Error-Correcting Codes |chapter=15.3 Arithmetic Codes / 15.6 Self-Complementing AN + B Codes |author-first1=William Wesley |author-last1=Peterson |author-link1=William Wesley Peterson |author-first2=Edward J. |author-last2=Weldon, Jr. |edition=2 |date=1972 |orig-year=February 1971, 1961 |publisher=The Massachusetts Institute of Technology (The MIT Press) |publication-place=Cambridge, Massachusetts, USA |location=Honolulu, Hawaii |isbn=0-262-16-039-0 |lccn=76-122262 |pages=454–456, 460–461 [456, 461]}} (xii+560+4 pages)

}}

Further reading

  • {{cite book |title=Design of Arithmetic Units for Digital Computers |author-first=John B. |author-last=Gosling |editor-first=Frank H. |editor-last=Sumner |date=1980 |edition=1 |publisher=The Macmillan Press Ltd |location=Department of Computer Science, University of Manchester, Manchester, UK |isbn=0-333-26397-9 |chapter=6.8.5 Exponent Representation |series=Macmillan Computer Science Series |pages=91, 137 |quote=[…] [w]e use a[n exponent] value which is shifted by half the binary range of the number. […] This special form is sometimes referred to as a biased exponent, since it is the conventional value plus a constant. Some authors have called it a characteristic, but this term should not be used, since CDC and others use this term for the mantissa. It is also referred to as an 'excess -' representation, where, for example, - is 64 for a 7-bit exponent (27−1 = 64). […]}}
  • {{anchor|Excess-6|Excess-11|Excess-123}} {{cite web |title=Decimal Representations |author-first=John J. G. |author-last=Savard |date=2018 |orig-year=2006 |work=quadibloc |url=http://www.quadibloc.com/comp/cp0203.htm |access-date=2018-07-16 |url-status=live |archive-url=https://web.archive.org/web/20180716101321/http://www.quadibloc.com/comp/cp0203.htm |archive-date=2018-07-16}} (NB. Mentions Excess-3, Excess-6, Excess-11, Excess-123.)
  • {{anchor|Excess-25|Excess-250}} {{cite web |title=Chen-Ho Encoding and Densely Packed Decimal |author-first=John J. G. |author-last=Savard |date=2018 |orig-year=2007 |work=quadibloc |url=http://www.quadibloc.com/comp/cp020301.htm |access-date=2018-07-16 |url-status=live |archive-url=https://web.archive.org/web/20180703002320/http://www.quadibloc.com/comp/cp020301.htm |archive-date=2018-07-03}} (NB. Mentions Excess-25, Excess-250.)
  • {{anchor|Excess-32|Excess-256|Excess-976|Excess-2048|Excess-16384}} {{cite web |title=Floating-Point Formats |author-first=John J. G. |author-last=Savard |date=2018 |orig-year=2005 |work=quadibloc |url=http://www.quadibloc.com/comp/cp0201.htm |access-date=2018-07-16 |url-status=live |archive-url=https://web.archive.org/web/20180703001709/http://www.quadibloc.com/comp/cp0201.htm |archive-date=2018-07-03}} (NB. Mentions Excess-32, Excess-64, Excess-128, Excess-256, Excess-976, Excess-1023, Excess-1024, Excess-2048, Excess-16384.)
  • {{anchor|Excess-500|Excess-512|Excess-1024}} {{cite web |title=Computer Arithmetic |author-first=John J. G. |author-last=Savard |date=2018 |orig-year=2005 |work=quadibloc |url=http://www.quadibloc.com/comp/cp02.htm |access-date=2018-07-16 |url-status=live |archive-url=https://web.archive.org/web/20180716102439/http://www.quadibloc.com/comp/cp02.htm |archive-date=2018-07-16}} (NB. Mentions Excess-64, Excess-500, Excess-512, Excess-1024.)

Category:Numeral systems

Category:Binary arithmetic