From: "Matthias Wächter" Date: 2007-09-04T03:05:58+09:00 Subject: Re: wierd floating point output On 03.09.2007 19:51, dblack@wobblini.net wrote: > On Tue, 4 Sep 2007, Matthias Wächter wrote: >> irb(main):002:0> 0.1.to_s >> => "0.1" >> >> I mean, irrespective of wrongly outputting 0.1 as "0.01" using >> .to_s, it cannot even correctly calculate the number using floating >> point printf-like string substitution! :( > > Where does it output "0.01"? *Sigh* -- I should proofread everything. The sentence should start with "I mean, irrespective of wrongly outputting 0.1 as "0.1" using .to_s, ..." What I mean is that any float stored as a IEEE 754 double (64 bit), like 0.1 with hex notation 0x3FB999999999999A should have a distinct string representation such that (a==b) == (a.to_s==b.to_s). Note that the next higher double 0.1+2.0**-56 with hex notation 0x3FB999999999999B has the same .to_s representation, which is not good. But that is discussed in another thread. - Matthias