From: Stefan Rusterholz Date: 2007-08-20T05:48:01+09:00 Subject: Re: Float addition problem / Processor bug? Christian Luginbuehl wrote: > I know that this is no Ruby-specific problem and I can live with it in a > more low level language like C, where a 'float' is represented by 32/64 > bits depending on your processor type, the same as an 'int' is stored as > a 32 bit (?) value. If you have an idea on how to do that, I'm sure the core developers would love to hear. The nature of the problem is not the same as with Fixnums vs. Bignums. With non-integral values your knowledge about the problem is required. Ruby provides several ways to deal with them, but it is upon you to choose the best way. There are Rational, BigDecimal and Float. Personally I don't see how the system should manage to automatically select "the best" variant, as that depends upon your needs. As far as I see it, those are not algorithmically ascertainable. What is IMHO arguable is to what literals default, e.g. whether 2.95 should mean Float("2.95") or BigDecimal("2.95") or Rational(295, 100). > I didn't but a lot of thinking in it, so there might be many issues to > solve. But again, it would be nice to have this behaviour in a > programming language that - generally very successfully - follows the > principle of least surprise (POLS). Yes, it would be nice. Just as far as I see it impossible. But some people love to solve seemingly impossible problems, so who knows... Regards Stefan -- Posted via http://www.ruby-forum.com/.