Colin Law wrote in post #970376:
> On 23 December 2010 03:41, Marnen Laibow-Koser <[email protected]>
> wrote:
>> 29114.999999999996362021192908287048
>>
>> It bears repeating: never, ever use Floats for arithmetic. If you can't
>> use fixed-point math, then use BigDecimal.
>
> I have to disagree here.

I knew someone would. :)

>  I would rephrase it as _almost_ never use
> Floats  The one time when they would be appropriate is if you have a
> large amount of arithmetic to perform.  The sort of thing that might
> occur in complex statistical analysis for example or engineering
> calculations of some sort.  On most (possibly all) computers floating
> point consumes vastly less processor time to perform than BigDecimal.

Then use fixed-point math.  IEEE floats are 100% inappropriate for any 
sort of mathematical calculation.  And who cares how fast they are if 
they're inaccurate?  Inaccurate engineering calculations are worse than 
none at all -- do *you* want to drive over that bridge? :)

If you want to use IEEE floats for arithmetic, then the onus is on you 
to do the requisite numerical analysis to figure out how much error you 
are introducing, and to inform your users of that fact.

> This is a rare occurence in Rails apps

Yes indeed!

> I expect so I agree that for
> most people Marnen's advice would be appropriate.
>
> Colin

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to