From: Jeremy Bopp Date: 2011-05-12T05:06:40+09:00 Subject: Re: Math cube root On 5/11/2011 14:45, Sergey Avseyev wrote: > How can you explain this: > > $ irb > 1.9.2p180 (main):001:0> 1000 ** (1.0/3) > 9.999999999999998 > 1.9.2p180 (main):002:0> Math.sqrt(100) > 10.0 You're using floating point arithmetic which is always inexact. The 1.0/3 part cannot be represented with infinite precision, so it's basically rounded at a certain point. The result is then used for the rest of the operation, which may compound the inaccuracy introduced by the initial rounding. If you must use floating point operations, be prepared to accept results that are only *close* to what you expect, where close is largely dependent on the operations being performed. http://en.wikipedia.org/wiki/Floating_point -Jeremy