In ARM VPF, why does the exponent part should add 127(in 32-bit) to represent the exponent?
In VPF 32-bit mode, a float number is store as follow:
31 30... ...23 22... ...0
S Exponent Mantissa
As for +0.5, the exponent is -1 ( +0.5 = 1*1*2^(-1) ). But in fact, the Exponent is stored as 126(-1+127), so I want ask why we should add a 127 then store the number in Exponent?
> But in fact, the Exponent is stored as 126(-1+127), so I want ask why we should add a 127 then store the number in Exponent?
... because that how IEEE 754 floating point encodes the exponent; it's not ARM VFP specific. See the part on exponent bias here:
Single-precision floating-point format - Wikipedia, the free encyclopedia
HTH,
Pete
But I want to know to store the exponent like this(add 127) have some advantages?
Exponent bias - Wikipedia, the free encyclopedia
The answer I copy it as follow from the wikipedia:
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.