From: Paul Smith Date: 2009-12-23T23:26:56+09:00 Subject: Re: Trig value errors On Wed, Dec 23, 2009 at 2:03 PM, Phillip Gawlowski wrote: > On 23.12.2009 08:15, jzakiya wrote: > >> This didn't nullify THE POINT I illustrated, which was >> using an increasingly smaller angle approaching zero as >> an argument, it eventually produced a value of '1' for >> cos, but not '0' for the same sin angle, as it should. No, it didn't. irb(main):020:0> x = cos(onedegree/1e06) => 1.0 irb(main):021:0> x - 1.0 => -1.11022302462516e-016 In the first line, I assign x the value of cos(small). The irb output of that number is 1.0. In the second line however, I show that x cannot be equal to 1.0, as there is a non-zero difference between them. (This is why you never check for equality of floats like this) So, cos(small) only looks like 1.0, it isn't actually equal to 1.0. Therefore it's not really much surprise than sin(small) isn't 0. -- Paul Smith http://www.nomadicfun.co.uk paul@pollyandpaul.co.uk