Guillaume Paris
Guillaume Paris

Reputation: 10539

representation of double and radix point

According to what I know on double (IEEE standard) there is one bit for signus, 54 bits for mantissa, a base and some bits for exponent

the formula to get the double is : (−1)^s × c × b^q

Maybe I made some mistake but the idea is here.

I'm just wondering how we can know where to put the radix point with this formula. If i take number, I get for instance:

m = 3
q = 4
s = 2
b = 2
(-1)^2 * 4 * 2^3 = 32

but I don't know where to put some radix point..

What is wrong here ?

EDIT:

Maybe q is always negative ?

Upvotes: 2

Views: 353

Answers (2)

Dialecticus
Dialecticus

Reputation: 16761

32 = 1 * 2^5, so mantissa=1, exponent=5, sign=0. We need to add 1023 to exponent when coding the exponent, so below we have 1023+5=1028. Also we need to remove digit 1 when coding mantissa, so that 1.(whatever) becomes (whatever)

Hexadecimal representation of 32 as 64-bit double is 4040000000000000, or binary:

0100 0000 0100 0000 0000 ... and zeros all the way down
               ^======== start of mantissa (coded 0, interpreted 1.0)
 ^===========^---------- exponent (coded 1028, interpreted 5)
^----------------------- sign (0)

To verify the result visit this page, enter 32 in first field, and click either Rounded or Not Rounded button (doesn't matter which one).

Upvotes: 1

Dodo
Dodo

Reputation: 195

I guess a look at the Wikipedia would've helped.

Thing is, that there is a "hidden" '1.' in the IEEE formula.

Every IEEE 754 number has to be normlized, this means that the encoded number is in the format:

(-1)^(sign) * '1.' (mantissa) * 2^(exponent)

Therefore, you have encoded 1.32, not 32.

Upvotes: 2

Related Questions