From: Marnen Laibow-Koser Date: 2009-11-15T23:01:53+09:00 Subject: Re: Trajectories James Edward Gray II wrote: > On Nov 14, 2009, at 7:41 PM, Marnen Laibow-Koser wrote: > >> But that's where BigDecimal comes in. It's clearly a floating-point >> number, but it's actually accurate. Semantically clear, numerically > > If you put BigDecimal against Float, I'm pretty darn certain you will > notice a very real speed difference. Ruby 1.8.7p72 on Mac OS 10.6.1: $ time ruby -rbigdecimal -e "1000.times{x = BigDecimal.new('3.5') * BigDecimal.new('4.2')}" real 0m0.009s user 0m0.005s sys 0m0.003s $ time ruby -rbigdecimal -e "a = BigDecimal.new('3.5'); b = BigDecimal.new('4.2'); 1000.times{x = a * b}" real 0m0.007s user 0m0.004s sys 0m0.003s $ time ruby -e "1000.times{x = 3.5 * 4.2}" real 0m0.008s user 0m0.004s sys 0m0.004s Looks darn close to me. > James Edward Gray II Best, -- Marnen Laibow-Koser http://www.marnen.org marnen@marnen.org -- Posted via http://www.ruby-forum.com/.