Hi,
On 7 April 2010 19:02, Yukihiro Matsumoto <matz / ruby-lang.org> wrote:

> Hi,
>
> As I stated in [ruby-core:27631], I don't object about having two
> string representation, one "human readable" and the other "more
> verbose".  Even though I am not fully against, it doesn't mean, I
> enjoy having two representation.  Float is float is float.  We should
> know about error when you treat with float, shouldn't we?
>
> Anyway, I feel like we still have two points:
>
> (1) We've got consensus which method to behave which so far.  Since
>    #inspect is a method for "human readable" string representation,
>    I think it is more suitable to get "human readable" float
>    representation.  Others want to #to_s to be "human readable" to
>    ease "Float #{f}".
>
> (2) Besides that, I am not sure whether the old behavior is the best
>    way to generate "human readable" representation.
>
>                                                        matz.
>
>
Then let's choose which representation is "human readable", maybe a third
one?

I spoke a bit about that in my last post, while I fear I'm more of a
beginner about technique:

So, double have a range (between two of them) of 2e-52 ~ 10e-16. Should we
then round at
15~16 digits ?

> n = 1.4 - 0.1 - 1.2
=> 0.09999999999999987
> "%.15f" % n
=> "0.100000000000000"
> "%.16f" % n
=> "0.0999999999999999"

So I think most people would agree with the "%.15f" result (without the
zeros of course).
The question is then: How to do it properly ?

P.S.: To my opinion, #inspect is usually more verbose than #to_s, so I
continue staying straight in my idea.
The bad thing with Float is you currently still need to "my Float: #{"%.2f"
% f}"
Inspect is, to my opinion, used mostly when debugging, almost never to print
result.
So if there is a verbose representation, I think it belongs to #inspect.
(I expect to have precise, even too verbose output when I 'p f')