MonkeeSage
11/29/2007 4:35:00 AM
On Nov 28, 9:49 pm, Gary Wright <gwtm...@mac.com> wrote:
> On Nov 28, 2007, at 4:20 PM, MenTaLguY wrote:
>
> > This comes up a lot, and I guess the thing that most people have a
> > hard time wrapping their heads around here is the fact that floating
> > point numbers don't obey the laws of basic math -- not exactly.
>
> That and the fact that internally numbers are represented in base 2
> and externally they are represented in base 10. Unfortunately there
> is not a one-to-one mapping between the two representations leading
> to inexact conversions and confusion. If evolution had given us four
> fingers on each hand and we counted in base 8 then maybe we could
> have avoided these problems. :-)
>
> Gary Wright
I think the OP understands about bases (if I may presume a bit here!).
What I think was a suprise to him was that the string representation
not only rounds, but presents a trailing ".0", as if it were accurate
to within one magnitude of 10. That is pretty much an arbitrary call,
as has been mentioned; and as the to_s method can be overridden in
ruby, it's not a problem at all. It's just a suprise if you're
expecting some (arbitrary) percision for the string representation
(e.g., the same percision used in GDB).
Regards,
Jordan