简体   繁体   中英

Floating-point mantissa and exponent base 2

I'm trying to understand how to get the mantissa and the exponent in this case. Here's an example I have in my book.

I have this formula (-1)^s * (1 + M) * b^Ee = x

s = 0 or 1 (the sign)
M = mantissa
b = base (In this case 2)
E = the exponent of this mantissa
e = 127 (for a 32bits system)

Still in by book, for x = 1.602177 * 10^-19, I get

S = 0,

M = 0.4777474,

E = 64

which it works.

1 * 1.4777474 * 2^-63 = 1.602 10^-19*

However, I don't know how to get the values for M and E .

I read that E = log b |x| then M = |x|b^-E

In this case E = log2(1.602177*10^-19) = -62.43660 (I'm using a website for the log base 2, so I'm not sure about the result so I tried E = -62 and -63).

M = (1.602177 * 10^-19) * 2^-(-62) = 0.7388737

M = (1.602177 * 10^-19) * 2^-(-63) = 1.4777474

Correct me if I'm wrong but the mantissa is the digits to the right of the floating point. In this case 0.4777474 looks right.

At this point I have E = -63 and M = 0.4777474, but E should be 64

I have E = -63 and M = 0.4777474, but E should be 64

Mathematically, the exponent is -63 as x = 1.602177 * 10^-19 is in the 2 -63 neighborhood. Yet the value stored is a 8-bit unsigned biased exponent with binary32 . Subtract the bias (-127) from the math exponent to get the biased exponent.

biased_exponent = expo - bias
64 = -63 - (-127)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM