Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The biggest/largest integer that can be stored in a double without losing precision is the same as the largest possible value of a double. That is, <code>DBL_MAX</code> or approximately 1.8&nbsp;×&nbsp;10<sup>308</sup> (if your double is an IEEE 754 64-bit double). It's an integer. It's represented exactly. What more do you want?</p> <p>Go on, ask me what the largest integer is, such that it <em>and all smaller integers</em> can be stored in IEEE 64-bit doubles without losing precision. An IEEE 64-bit double has 52 bits of mantissa, so I think it's 2<sup>53</sup>:</p> <ul> <li>2<sup>53</sup> + 1 cannot be stored, because the 1 at the start and the 1 at the end have too many zeros in between. </li> <li>Anything less than 2<sup>53</sup> can be stored, with 52 bits explicitly stored in the mantissa, and then the exponent in effect giving you another one. </li> <li>2<sup>53</sup> obviously can be stored, since it's a small power of 2.</li> </ul> <p>Or another way of looking at it: once the bias has been taken off the exponent, and ignoring the sign bit as irrelevant to the question, the value stored by a double is a power of 2, plus a 52-bit integer multiplied by 2<sup>exponent&nbsp;−&nbsp;52</sup>. So with exponent 52 you can store all values from 2<sup>52</sup> through to 2<sup>53</sup>&nbsp;−&nbsp;1. Then with exponent 53, the next number you can store after 2<sup>53</sup> is 2<sup>53</sup> + 1&nbsp;×&nbsp;2<sup>53 − 52</sup>. So loss of precision first occurs with 2<sup>53</sup> + 1.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload