Hi,

2010/4/1 Marc-Andre Lafortune <redmine / ruby-lang.org>:
> 1) First, there is currently a bug in trunk:
>
> 72.9.to_s # ==> "72.90000000000001"
>
> This is plainly wrong.

I guess that your story is not logical.

Consider 72.90000000000001.to_s.  With your suggestion, it will return
"72.9".  Don't you complain the behavior?

I think Float#to_s can select any representation.  Any representation
is not "wrong", and


> #to_s (and #inspect) should choose the simplest string representation that is included in the approximate range a float represents.

it is the best representation, I agree.

I wonder whether or not the suggestion is included in 1.9.2...


> 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"
>
> I object to this, because 1-0.9 is not == to 0.1 and thus should not have the same string representation.

Agreed.

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