Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decimal to floating point

If I wanted to convert a number Ex. 32.24x10^5 to IEEE 754 standard BY HAND how would I do it?

like image 774
Icestorm Avatar asked Apr 22 '26 20:04

Icestorm


1 Answers

First, read and familiarize yourself with some information about the format. Then convert the whole number to binary. Then determine the exponent (power of two of course) to normalize the mantissa. Then encode the mantissa in the appropriate bits and the exponent in the appropriate bits.

32.24E5 = 3224000
= 1100010011000111000000b
= 1.100010011000111000000b E 21 (that's 2^21)
= 1.100010011000111000000b E 10101b

So now, encode the two values into the exponent portion and the mantissa portion (keep in mind that the leading one in the mantissa isn't included, it's assumed to be one always (depending on the format, hence the familiarize step)).

like image 115
JoshD Avatar answered Apr 24 '26 08:04

JoshD