Skip to content
Prev 312312 / 398521 Next

Ceiling function gives me wrong answer

This is another variation on FAQ 7.31.  You are trying to calculate the cube  root using a power of 1/3.  But 1/3 cannot be represented exactly in a finite binary floating-point system.  If you print the value of b with enough digits you will see that it is not equal to 10 because the representation of the value 1/3 ends up being slightly smaller that one-third.
[1] 0.33333333333333331483
[1] 9.9999999999999982236


Hope this is helpful,

Dan

Daniel Nordlund
Bothell, WA USA