From: Phrogz Date: 2009-12-23T14:10:28+09:00 Subject: Re: Trig value errors On Dec 22, 7:08 pm, jzakiya wrote: > Hardware: 32-bit Intel P4 cpu [snip] > Ruby 1.9.1p243 output below > > 1)onedegree =2*PI/360 =>0.0241660973353061 Seriously? I don't believe it. Here's what I get: irb(main):001:0> RUBY_VERSION => "1.9.1" irb(main):002:0> include Math => Object irb(main):003:0> onedegree = 2*PI/360 => 0.0174532925199433 That's HUGELY different from the value you get. I am now suspicious of the rest of your results. > 6)cos onedegree/1e06  =>1.0 Sort of. Here's what I get: irb(main):004:0> x = cos(onedegree/1e06) => 1.0 irb(main):005:0> x - 1.0 => -1.11022302462516e-16 irb(main):006:0> puts "%.30f" % x 0.999999999999999888977697537484 > Examples 4)-9) show that at some point for cos a > decision was made to fix (roundoff.truncation,?) > cos(of a very smal number) = 1.0 False. What they show is that the string representation of floating point values doesn't always show you the full picture.