Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why IEEE floating point number calculate exponent using a biased form?

let's say, for the float type in c, according to the IEEE floating point specification, there are 8-bit used for the fraction filed, and it is calculated as first taken these 8-bit and translated it into an unsigned number, and then minus the BIASE, which is 2^7 - 1 = 127, and the result is an exponent ranges from -127 to 128, inclusive. But why can't we just treat these 8-bit pattern as a signed number, since the resulting range is [-128,127], which is almost the same as the previous one.

like image 925
mochidino Avatar asked Apr 10 '10 08:04

mochidino


People also ask

Why exponent of a floating point number is used in biased form?

The biased exponent is used for the representation of negative exponents. The biased exponent has advantages over other negative representations in performing bitwise comparing of two floating point numbers for equality. The range of exponent in single precision format is -128 to +127.

What is the meaning of biased exponent state the values of bias in the IEEE 754 1985 single and double precision formats respectively?

biased exponent = −3 + the "bias". In single precision, the bias is 127, so in this example the biased exponent is 124; in double precision, the bias is 1023, so the biased exponent in this example is 1020. fraction = . 01000…2.

What is exponent in floating-point numbers?

The exponent is the component of a finite floating-point representation that signifies the integer power to which the radix is raised in determining the value of that floating-point representation.

What bias should be used in the exponent if we prefer all exponents to be non negative?

For all non-negative exponents, we would need a bias of 4. 20. Assume we are using the simple model for floating-point representation as given in this book (the representation uses a 14-bit format, 5 bits for the exponent with a bias of 16, a normalized mantissa of 8 bits, and a single sign bit for the number): a.


1 Answers

The purpose of the bias is so that the exponent is stored in unsigned form, making it easier to do comparisons. From Wikipedia:

By arranging the fields so 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 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.

So basically, a floating point number is:

[sign] [unsigned exponent (aka exponent + bias)] [mantissa]

This website provides excellent information about why this is good - specifically, compare the implementations of floating point comparison functions.

Also, no complete answer about floating point oddities can go without mentioning "What Every Computer Scientist Should Know About Floating-Point Arithmetic." It's long, dense and a bit heavy on the math, but it's long dense mathematical gold (or something like that).

like image 173
Daniel G Avatar answered Sep 28 '22 10:09

Daniel G