Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The test fails, because you have reached the accuracy of the binary floating point representation, which is approximately 16 digits with <a href="http://en.wikipedia.org/wiki/Double_precision" rel="nofollow noreferrer">IEEE754 double precision</a>. Multiplying by 649632196443.4279 by 10000 will truncate the binary representation, leading to errors when rounding and dividing afterwards, thereby invalidating the result of your function completely.</p> <p>For more details see <a href="http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems</a></p> <p>A better way would be to check whether the <code>n+1</code> decimal places are below a certain threshold. If <code>d - round(d)</code> is less than <a href="http://en.wikipedia.org/wiki/Epsilon" rel="nofollow noreferrer"><code>epsilon</code></a> (see <a href="http://en.wikipedia.org/wiki/Limit_(mathematics)" rel="nofollow noreferrer">limit</a>), the decimal representation of <code>d</code> has no significant decimal places. Similarly if <code>(d - round(d)) * 10^n</code> is less than <code>epsilon</code>, d can have at most <code>n</code> significant places. </p> <p>Use <a href="https://stackoverflow.com/users/22656/jon-skeet">Jon Skeet</a>'s <a href="http://pobox.com/~skeet/csharp/DoubleConverter.cs" rel="nofollow noreferrer"><code>DoubleConverter</code></a> to check for the cases where <code>d</code> isn't accurate enough to hold the decimal places you are looking for.</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