Jump to content

Exponent bias

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 64.106.111.10 (talk) at 21:50, 25 September 2013. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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

To solve this problem the exponent is biased before being stored, by adjusting its value to put it within an unsigned range suitable for comparison.

By arranging the fields so that the sign bit is in the most significant bit position, the biased exponent in the middle, then the mantissa in the least significant bits, the resulting value will be ordered properly, whether it's interpreted as a floating point or integer value. This allows high speed comparisons of floating point numbers using fixed point hardware.

To calculate the bias for an arbitrary sized floating point number apply the formula 2^(k-1) where k is the number of bits in the exponent.[1]

When interpreting the floating-point number, the bias is subtracted to retrieve the actual exponent.

  • For a single-precision number, an exponent in the range −126 .. +127 is biased by adding 127 to get a value in the range 1 .. 254 (0 and 255 have special meanings).
  • For a double-precision number, an exponent in the range −1022 .. +1023 is biased by adding 1023 to get a value in the range 1 .. 2046 (0 and 2047 have special meanings).
  • For a quad-precision number, an exponent in the range −16382 .. +16383 is biased by adding 16383 to get a value in the range 1 .. 32766 (0 and 32767 have special meanings).

See also

  1. ^ O'Hallaron, Randal E. Bryant, David R. (2010). Computer systems : a programmer's perspective (2nd ed. ed.). Boston: Prentice Hall. ISBN 978-0-13-610804-7. {{cite book}}: |edition= has extra text (help)CS1 maint: multiple names: authors list (link)