1
$\begingroup$

I am reading a numerical analysis book, and it talks about nearest numbers.

They quickly state that you can find the nearest machine numbers easily, but never go on to show how to,find those numbers.

Can someone please explains how you can find the two closest numbers of a given number $y$ where $y'$ is the number below and $y''$ is the number above for double precision?

Let say the number is $y = 0.8$.

How do you number the closest number above and below that number in double precision?

1 Answers 1

2

You would have to determine the 53 binary digits of the mantissa in $$ x=2^e·(1.m_1…m_{53})_2 $$ The exponent is obtained from the condition $2^e\le x <2^{e+1}$. Then for the mantissa compute the integer part of $x·2^{53-e}$.

As for $x=0.8$ you get $e=-1$, you need to compute the integer part of $0.8·2^{54}$, $14411518807585587$, and its successor, $14411518807585588$, (and additionally the binary representation of them if you want to construct the floating point format).

  • 0
    thank you for this, is the integer part the mantissa?2017-01-30
  • 0
    Yes. The integer part is the mantissa.2017-01-30