0
$\begingroup$

$1.75\times10^{15}$

I know how to convert decimal to binary

$(1.75)_{10}$ is equal to $(1.11)_2$

But to represent $10^{15}$ is the main problem for me. I can solve the question but this is the point where I got stuck. How can I represent $10^{15}$ in base 2 ?

$\endgroup$
  • 1
    $\begingroup$ What about converting 1750000000000000 to binary? Because that's the exact same number. $\endgroup$ – gnasher729 May 25 at 12:59
  • $\begingroup$ There's a big difference between writing $1.75\times 10^{15}$ in binary, and writing it in IEEE-32 (single precision floating point) form. I answer below to the latter. The former is done by remembering that 1 in the $i$-th place has a value of $2^{i}$ (where the place left to the dot is place 0). $\endgroup$ – Ran G. May 25 at 14:19
  • $\begingroup$ @RanG. Asking how to convert 1750000000000000 shows that converting 1.75 does nothing whatsoever that helps with the problem. And of course 99% of the conversion to IEEE-754 single precision format is done at that point. $\endgroup$ – gnasher729 May 25 at 16:55
  • $\begingroup$ 1.75 × 10^15 = 110001101111001110110100000010110110110000000000000b = 1.1000110111100111011010000001011011011 × 2^50 $\endgroup$ – TEMLIB Jun 26 at 1:13
1
$\begingroup$

You need to understand how the IEEE-754 standard for floating point numbers works. It is not simply converting the number to binary.

Instead, the 32 bits that compose the representation of the floating-point number are split into 3 fields: sign, exponent, mantissa. Their sizes are 1bit, 8bit, and 23bit, respectively. Each field is written in binary basis (unsigned).

If the value of the exponent field is $e$, and the value of the mantissa field is $m$ then, the these 32bits represent the number $$ 2^{e-127} \times (1 + m\cdot 2^{-23})$$ the $s$ bit determines if the number is positive or negative.

So, to represent the number $1.5\cdot 10^{15}$ you will need to set: $s=0$ (positive), $e=177$, and $m=2787263$. Calculate $2^{e-127} \times (1 + m\cdot 2^{-23}) = 2^{50} + 2787263\cdot 2^{27} = 1500000014041088$, which is the closest you can get to $1.5\cdot 10^{15}$ with 32bit representation.

Use https://www.h-schmidt.net/FloatConverter/IEEE754.html as a simple converter and a way to learn how this representation works.


(Oops, I demonstrated the above for 1.5e15, while the question was about 1.75e15. Nevermind, replace with $m=4649908$ to get 1.74999999e15).

$\endgroup$
  • $\begingroup$ Please let me know how you converted $10^{15}$ to $2^{50}$. Did you change the base using Logarithm ? $\endgroup$ – Inside May 26 at 7:33
  • $\begingroup$ That's not how it works. Look again at the explanation. You need to find $e$ and $m$ that satisfy $2^{e-127}(1+m/2^{23})=1.75\cdot10^{15}$. The constraints are $0\le e \le 255$, and $0 \le m \le 2^{23}-1$. $\endgroup$ – Ran G. May 26 at 16:57
  • $\begingroup$ I got the point that the number is split according to $2^{e-127}(1+m/2^{23})=1.75\cdot10^{15}$. I also understand that it must satisfy the condition as you mentioned above. But I want to know how you split exponent and mantissa. How you split mantissa=$4649908$ and exponent=$2^{50}$ Is there any formula. I know that to represent a number in floating point IEEE 32 bit format, we first convert the number in binary, then we normalize and bias the exponent and finally we write in the format $\pm(1.N)2^{E-127}$. $\endgroup$ – Inside May 27 at 8:13
  • $\begingroup$ See a step by step conversion algorithm in blog.penjee.com/binary-numbers-floating-point-conversion $\endgroup$ – Ran G. May 27 at 18:37
  • $\begingroup$ The steps shown in (blog.penjee.com/binary-numbers-floating-point-conversion) are the same way I learnt to convert. The blog shows an example by converting $34.890625$ first to its binary form and then doing the other steps. My question was $1.75\times10^{15}$ which is equal to $1750000000000000$. How can I convert such a long number to its binary form, it is time consuming. Is there any way or shortcut to represent that long number. How do you extracted the exponent $2^{50}$.Just show me the calculation how you did for $m=4649908$ and $e=2^{50}$. your answer will be very helpful. $\endgroup$ – Inside May 28 at 8:21
0
$\begingroup$

In this example: $1.75 \cdot 10^{15} = 175 \cdot 10^{13}$.

Quick and dirty: You convert 175 into a floating point number, lookup $10^{13}$ in a table, and multiply the two numbers.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.