Offset binary

Last updated

Offset binary, [1] also referred to as excess-K, [1] excess-N, excess-e, [2] [3] 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 is 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.

Contents

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

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). [4]

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).

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. [5]

Most standard computer CPU chips cannot handle the offset binary format directly[ citation needed ]. 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: [6]

DecimalOffset binary,
K = 8
Two's
complement
711110111
611100110
511010101
411000100
310110011
210100010
110010001
010000000
−101111111
−201101110
−301011101
−401001100
−500111011
−600101010
−700011001
−800001000

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.

[2] [3] [7]
Code comparison [2] [3] [7]
CodeTypeParameters Weights Distance Checking Complement Groups of 5Simple addition
Offset, kWidth, nFactor, q
8421 code n [8] 0418 4 2 11–4NoNoNoNo
Nuding code [8] [9] 3n + 2 [8] 253N/A2–5Yes9YesYes
Stibitz code [10] n + 3 [8] 3418  4 −2 −11–4No9YesYes
Diamond code [8] [11] 27n + 6 [8] [12] [13] 6827N/A3–8Yes9YesYes
25n + 15 [12] [13] 15825N/A3+YesYes ?Yes
23n + 24 [12] [13] 24823N/A3+YesYes ?Yes
19n + 42 [12] [13] 42819N/A3–8Yes9YesYes
Decimal
 
0
1
2
3
4
5
6
7
8
9
8421
4321
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
Stibitz [10]
4321
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
Nuding [8] [9]
54321
00010
00101
01000
01011
01110
10001
10100
10111
11010
11101
Diamond [8]
87654321
00000110
00100001
00111100
01010111
01110010
10001101
10101000
11000011
11011110
11111001
19n + 42 [12] [13]
87654321
00101010
00111101
01010000
01100011
01110110
10001001
10011100
10101111
11000010
11010101

See also

Related Research Articles

Binary-coded decimal System of digitally encoding numbers

In computing and electronic systems, binary-coded decimal (BCD) is a class of binary encodings of decimal numbers where each digit is represented by a fixed number of bits, usually four or eight. Sometimes, special bit patterns are used for a sign or other indications.

Floating-point arithmetic Computer approximation for real numbers

In computing, floating-point arithmetic (FP) is arithmetic using formulaic representation of real numbers as an approximation to support a trade-off between range and precision. For this reason, floating-point computation is often used in systems with very small and very large real numbers that require fast processing times. In general, a floating-point number is represented approximately with a fixed number of significant digits and scaled using an exponent in some fixed base; the base for the scaling is normally two, ten, or sixteen. A number that can be represented exactly is of the following form:

IEEE 754-1985 was an industry standard for representing floating-point numbers in computers, officially adopted in 1985 and superseded in 2008 by IEEE 754-2008, and then again in 2019 by minor revision IEEE 754-2019. During its 23 years, it was the most widely used format for floating-point computation. It was implemented in software, in the form of floating-point libraries, and in hardware, in the instructions of many CPUs and FPUs. The first integrated circuit to implement the draft of what was to become IEEE 754-1985 was the Intel 8087.

A computer number format is the internal representation of numeric values in digital device hardware and software, such as in programmable computers and calculators. Numerical values are stored as groupings of bits, such as bytes and words. The encoding between numerical values and bit patterns is chosen for convenience of the operation of the computer; the encoding used by the computer's instruction set generally requires conversion for external use, such as for printing and display. Different types of processors may have different internal representations of numerical values and different conventions are used for integer and real numbers. Most calculations are carried out with number formats that fit into a processor register, but some software systems allow representation of arbitrarily large numbers using multiple words of memory.

Double-precision floating-point format is a computer number format, usually occupying 64 bits in computer memory; it represents a wide dynamic range of numeric values by using a floating radix point.

The IEEE Standard for Floating-Point Arithmetic is a technical standard for floating-point arithmetic established in 1985 by the Institute of Electrical and Electronics Engineers (IEEE). The standard addressed many problems found in the diverse floating-point implementations that made them difficult to use reliably and portably. Many hardware floating-point units use the IEEE 754 standard.

The significand is part of a number in scientific notation or in floating-point representation, consisting of its significant digits. Depending on the interpretation of the exponent, the significand may represent an integer or a fraction.

In computing, fixed-point refers to a method of representing fractional (non-integer) numbers by storing a fixed number of digits of their fractional part. Dollar amounts, for example, are often stored with exactly two fractional digits, representing the cents. More generally, the term may refer to representing fractional values as integer multiples of some fixed small unit, e.g. a fractional amount of hours as an integer multiple of ten-minute intervals. Fixed-point number representation is often contrasted to the more complicated and computationally demanding floating-point representation.

Excess-3, 3-excess or 10-excess-3 binary code, shifted binary or Stibitz code is a self-complementary binary-coded decimal (BCD) code and numeral system. It is a biased representation. Excess-3 code was used on some older computers as well as in cash registers and hand-held portable electronic calculators of the 1970s, among other uses.

Hexadecimal floating point is a format for encoding floating-point numbers first introduced on the IBM System/360 computers, and supported on subsequent machines based on that architecture, as well as machines which were intended to be application-compatible with System/360.

In computing, signed number representations are required to encode negative numbers in binary number systems.

In IEEE 754 floating-point numbers, the exponent is biased in the engineering sense of the word – the value stored is offset from the actual value by the exponent bias, also called a biased exponent. Biasing is done because exponents have to be signed values in order to be able to represent both tiny and huge values, but two's complement, the usual representation for signed values, would make comparison harder.

Signed zero is zero with an associated sign. In ordinary arithmetic, the number 0 does not have a sign, so that −0, +0 and 0 are identical. However, in computing, some number representations allow for the existence of two zeros, often denoted by −0 and +0, regarded as equal by the numerical comparison operations but with possible different behaviors in particular operations. This occurs in the sign and magnitude and ones' complement signed number representations for integers, and in most floating-point number representations. The number 0 is usually encoded as +0, but can be represented by either +0 or −0.

Decimal floating-point (DFP) arithmetic refers to both a representation and operations on decimal floating-point numbers. Working directly with decimal (base-10) fractions can avoid the rounding errors that otherwise typically occur when converting between decimal fractions and binary (base-2) fractions.

The IEEE 754-2008 standard includes decimal floating-point number formats in which the significand and the exponent can be encoded in two ways, referred to as binary encoding and decimal encoding.

In computing, half precision is a binary floating-point computer number format that occupies 16 bits in computer memory. It is intended for storage of floating-point values in applications where higher precision is not essential, in particular computer graphics images and neural networks.

In computing, quadruple precision is a binary floating point–based computer number format that occupies 16 bytes with precision at least twice the 53-bit double precision.

Single-precision floating-point format is a computer number format, usually occupying 32 bits in computer memory; it represents a wide dynamic range of numeric values by using a floating radix point.

In computing, octuple precision is a binary floating-point-based computer number format that occupies 32 bytes in computer memory. This 256-bit octuple precision is for applications requiring results in higher than quadruple precision. This format is rarely used and very few environments support it.

The bfloat16 floating-point format is a computer number format occupying 16 bits in computer memory; it represents a wide dynamic range of numeric values by using a floating radix point. This format is a truncated (16-bit) version of the 32-bit IEEE 754 single-precision floating-point format (binary32) with the intent of accelerating machine learning and near-sensor computing. It preserves the approximate dynamic range of 32-bit floating-point numbers by retaining 8 exponent bits, but supports only an 8-bit precision rather than the 24-bit significand of the binary32 format. More so than single-precision 32-bit floating-point numbers, bfloat16 numbers are unsuitable for integer calculations, but this is not their intended use. Bfloat16 is used to reduce the storage requirements and increase the calculation speed of machine learning algorithms.

References

  1. 1 2 Chang, Angela; Chen, Yen; Delmas, Patrice (2006-03-07). "2.5.2: Data Representation: Offset binary representation (Excess-K)". COMPSCI 210S1T 2006 (PDF). Department of Computer Science, The University of Auckland, NZ. p. 18. Retrieved 2016-02-04.
  2. 1 2 3 Dokter, Folkert; Steinhauer, Jürgen (1973-06-18). Digital Electronics. Philips Technical Library (PTL) / Macmillan Education (Reprint of 1st English ed.). Eindhoven, Netherlands: The Macmillan Press Ltd. / N. V. Philips' Gloeilampenfabrieken. p. 44. doi:10.1007/978-1-349-01417-0. ISBN   978-1-349-01419-4. SBN   333-13360-9 . Retrieved 2018-07-01. (270 pages) (NB. This is based on a translation of volume I of the two-volume German edition.)
  3. 1 2 3 Dokter, Folkert; Steinhauer, Jürgen (1975) [1969]. "2.4.4.4. Exzeß-e-Kodes". Digitale Elektronik in der Meßtechnik und Datenverarbeitung: Theoretische Grundlagen und Schaltungstechnik. Philips Fachbücher (in German). Vol. I (improved and extended 5th ed.). Hamburg, Germany: Deutsche Philips GmbH. pp. 51, 53–54. ISBN   3-87145-272-6. (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.)
  4. IBM System/360 Principles of Operation Form A22-6821. Various editions available on the WWW.[ page needed ]
  5. Electrical and Computer Science Department, Southeastern Massachusetts University, North Dartmouth, MA, USA (1988). Chen, Chi-hau (ed.). Signal Processing Handbook. New York, USA: Marcel Dekker, Inc./CRC Press. ISBN   0-8247-7956-8 . Retrieved 2016-02-04.
  6. "Data Conversion Binary Code Formats" (PDF). Intersil Corporation (published 2000). May 1997. AN9657.1. Retrieved 2016-02-04.
  7. 1 2 Morgenstern, Bodo (January 1997) [July 1992]. "10.5.3.5 Excess-e-Code". Elektronik: Digitale Schaltungen und Systeme. Studium Technik (in German). Vol. 3 (revised 2nd ed.). Friedrich Vieweg & Sohn Verlagsgesellschaft mbH. pp. 120–121. doi:10.1007/978-3-322-85053-9. ISBN   978-3-528-13366-5 . Retrieved 2020-05-26. (xviii+393 pages)
  8. 1 2 3 4 5 6 7 8 Diamond, Joseph M. (April 1955) [1954-11-12]. "Checking Codes for Digital Computers". Proceedings of the IRE . Correspondence. New York, USA. 43 (4): 483–490 [487–488]. doi:10.1109/JRPROC.1955.277858. eISSN   2162-6634. ISSN   0096-8390. Archived from the original on 2020-05-26. Retrieved 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.)
  9. 1 2 Nuding, Erich (1959-01-01). "Ein Sicherheitscode für Fernschreibgeräte, die zur Ein- und Ausgabe an elektronischen Rechenmaschine verwendet werden". Zeitschrift für Angewandte Mathematik und Mechanik. Kleine Mitteilungen (in German). 39 (5–6): 429. Bibcode:1959ZaMM...39..249N. doi:10.1002/zamm.19590390511. (1 page)
  10. 1 2 Stibitz, George Robert (1954-02-09) [1941-04-19]. "Complex Computer". Patent US2668661A. Retrieved 2020-05-24. (102 pages)
  11. Plotkin, Morris (September 1960). "Binary Codes with Specified Minimum Distance". IRE Transactions on Information Theory . IT-6 (4): 445–450. doi:10.1109/TIT.1960.1057584. eISSN   2168-2712. ISSN   0096-1000. S2CID   40300278. (NB. Also published as Research Division Report 51-20 of University of Pennsylvania in January 1951.)
  12. 1 2 3 4 5 Brown, David T. (September 1960). "Error Detecting and Correcting Binary Codes for Arithmetic Operations". IRE Transactions on Electronic Computers . EC-9 (3): 333–337. doi:10.1109/TEC.1960.5219855. ISSN   0367-9950. S2CID   28263032.
  13. 1 2 3 4 5 Peterson, William Wesley; Weldon, Jr., Edward J. (1972) [February 1971, 1961]. "15.3 Arithmetic Codes / 15.6 Self-Complementing AN + B Codes". Written at Honolulu, Hawaii. Error-Correcting Codes (2 ed.). Cambridge, Massachusetts, USA: The Massachusetts Institute of Technology (The MIT Press). pp. 454–456, 460–461 [456, 461]. ISBN   0-262-16-039-0. LCCN   76-122262. (xii+560+4 pages)

Further reading