Need help converting a number into IEEE floating point format

1.4k Views Asked by At

I need to convert the number $74 \frac{5}{14}$ into IEEE floating point format. Can someone help me with this

3

There are 3 best solutions below

4
On

This tool does the job nicely, with single or double precision as desired.

Conversion

2
On

$74_\text{ten}=1001010_\text{two}$

To convert a number between $0$ and $1$ to binary, write a binary point '.'

  1. multiply by two
  2. copy the integer part to the binary representation
  3. retain the fractional part
  4. go to 1.

For $\frac{5}{14}$ we get $.01011011011011011011$. Thus, the binary for $74\frac{5}{14}$ is $$ 1001010.01011011011011011=1.00101001011011011011011\times2^6 $$


The floating point representation is a sign bit (0 = positive, 1 = negative), the exponent of 2 plus 127 (8 bits), the mantissa without the leading '1' (23 bits): $$ \overbrace{0}^\text{sign bit}\overbrace{10000101}^\text{exponent}\ \overbrace{00101001011011011011011}^\text{mantissa} $$ If we wish to convert to hexadecimal, we have $$ 0\text{x}4294\text{B}6\text{DB} $$


The double precision representation is a sign bit (0 = positive, 1 = negative), the exponent of 2 plus 1023 (11 bits), the mantissa without the leading '1' (52 bits): $$ \overbrace{0}^\text{sign bit} \overbrace{10000000101}^\text{exponent}\ \overbrace{0010 1001 0110 1101 1011 0110 1101 1011 0110 1101 1011 0110 1101}^\text{mantissa} $$ If we wish to convert to hexadecimal, we have $$ 0\text{x}405296\text{DB}6\text{DB}6\text{DB}6\text{D} $$

0
On

Another tool that I use all the time.