Hi,

2010/4/1 Benoit Daloze <eregontp / gmail.com>:
>> 1) First, there is currently a bug in trunk:
>>
>> 72.9.to_s # ==> "72.90000000000001"
>>
>> #to_s (and #inspect) should choose the simplest string representation that is included in the approximate range a float represents.
>
> That's what we ask for #to_s

No.  You are asking the different behavior from Marc-Andre.

Marc-Andre is insisting it choose the simplest representation
*without inaccuracy*.  But the old behavior you want chooses
a simple one *that may be even inaccurate*.


>> 2) Calculations between floats introduce errors due to these approximations. For example:
>>
>> (1-0.9) == 0.1 # ==> false
>>
>> This feature request asks that (1-0.9).to_s ?# => "0.1"
>
> No, but it's one consequence. 1.8 behave like this. Nobody would ever
> want to compare the String representations to compare the value...

Even in 1.8, the following returns the result including error:

  p 1.4 - 0.1 - 1.2  #=> 0.0999999999999999

It may cause a bug that is hard to test and reproduce.


Honestly, I used to like the old behavior.  But I knew that the
implementation of the old behavior was very uncool and dirty.
It is almost like:

  ("%.15f" % float).sub(/0+$/, "")

Now I dislike the old behavior.

-- 
Yusuke ENDOH <mame / tsg.ne.jp>