, also referred to as excess-K
, is a digital coding scheme where all-zero corresponds to the minimal negative value and all-one to the maximal positive value
In computer programming, an integer overflow occurs when an arithmetic operation attempts to create a numeric value that is too large to be represented within the available storage space. For instance, adding 1 to the largest value that can be represented constitutes an integer overflow...
. There is no standard for offset binary, but most often the offset K for an n-bit binary word is K=2^(n-1). This has the consequence that the "zero" value is represented by a 1 in the most significant bit and zero in all other bits, and in general the effect is conveniently the same as using two's complement
The two's complement of a binary number is defined as the value obtained by subtracting the number from a large power of two...
except that 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 twos' complement numerical comparison operation, whereas, in twos' complement notation a logical comparison will agree with twos' complement 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.
One historically prominent example of offset-64 ("excess 64") notation was in the floating point
In computing, floating point describes a method of representing real numbers in a way that can support a wide range of values. Numbers are, in general, represented approximately to a fixed number of significant digits and scaled using an exponent. The base for the scaling is normally 2, 10 or 16...
(exponential) notation in the IBM System/360 and System/370 generations of computers. The "characteristic" (exponent) took the form of an seven-bit excess-64 number (The high-order bit of the same byte contained the sign of the significand
The significand is part of a floating-point number, consisting of its significant digits. Depending on the interpretation of the exponent, the significand may represent an integer or a fraction.-Examples:...
). The IEEE Standard for Floating-Point Arithmetic (IEEE 754) uses various sizes of exponent, but also uses offset notation for the format of each precision. Unusually however, instead of using "excess 2^(n-1)" it uses "excess 2^(n-1)-1" which means that inverting the leading (high-order) bit of the exponent will not convert the exponent to correct twos' complement notation.
Offset binary is often used in digital signal processing
Digital signal processing is concerned with the representation of discrete time signals by a sequence of numbers or symbols and the processing of these signals. Digital signal processing and analog signal processing are subfields of 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 signal
In telecommunication, a bipolar signal is a signal that may assume either of two polarities, neither of which is zero.A bipolar signal may have a two-state non-return-to-zero or a three-state return-to-zero binary coding scheme....
s (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. 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. Notice that as a consequence of the fact that the commonest offset for an n-bit word is 2^(n-1), which implies that the first bit is inverted relative to twos' complement, one need not have a separate subtraction step, but simply can invert the first bit. This sometimes is a useful simplification in hardware, and can be convenient in software as well.
Offset binary occurs so frequently in digital signal processing that many DSP chips can handle offset binary without requiring any data conversion.
Table of offset binary for 4 bits, with twos' complement for comparison
| Offset Binary code, K=8
|| Decimal code
|| Twos' complement Binary
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 XOR'ed 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.