From: George Neuner Date: 2010-05-08T10:05:05+09:00 Subject: Re: ruby 1.9+ , floats, and decimal On Sun, 18 Apr 2010 22:07:34 -0500, botp wrote: >in the spirit of advancing to a better computing env, shouldn't it be >time for ruby to default to "real" decimal instead of float? > >arguments: > > 1. ruby using the dot decimal notation, for sure that is a decimal >notation (and ruby is not c) > 2. we remove 99% of deci gotchas > 3. there is always #to_f. we can put it to better use (if you want >speed and not precision). Default behavior? I don't know whether it's a good idea or not. On one hand, it supports the principle of least surprise for newbies ... but on the other hand it keeps legions of programmers clueless about reality. Lisp defaults to precise arithmetic but falls back on imprecise binary floating point under a whole bunch of corner conditions ... and imprecision is contagious ... any operation that involves an imprecise operand produces an imprecise result. The Lisp standard committee spent a very great deal of time defining the conditions under which arithmetic should produce precise or imprecise results. But the rules are many and too confusing ... I've seen experienced Lisp programmers panic when they trigger an imprecise result, or when they try to integrate Lisp with libs in other languages (C, Fortran, etc.) that don't have precise arithmetic. I can see supporting parallel numeric towers - one precise and an imprecise, performance oriented one - and letting the programmer decide which to use. But in that case, I think there should only be explicit conversions between them. But I also think programmers need to understand how floating point hardware operates because, if they become professional, sooner or later they will have to deal with it. George