[#23231] What do you think about changing the return value of Kernel#require and Kernel#load to the source encoding of the required file? — =?ISO-8859-15?Q?Wolfgang_N=E1dasi-Donner?= <ed.odanow@...>

Dear Ruby developers and users!

8 messages 2009/04/17

[#23318] [Feature #1408] 0.1.to_r not equal to (1/10) — Heesob Park <redmine@...>

Feature #1408: 0.1.to_r not equal to (1/10)

19 messages 2009/04/26

[ruby-core:23126] Re: [Bug #1336] Change in string representation of Floats

From: Daniel Luz <dev@...>
Date: 2009-04-05 20:12:54 UTC
List: ruby-core #23126
On Sun, Apr 5, 2009 at 15:23, Brent Roman <brent@mbari.org> wrote:
> Python, however, does output 2.3999...

Actually, as I explained earlier, Python has str() (parallel to Ruby's
#to_s) and repr() (similar to Ruby's #inspect). str(2.4) returns
'2.4', repr(2.4) returns '2.3999...'. What you're seeing is probably
that you're just typing something on the interactive interpreter; like
irb, it shows the result using repr/inspect. You should type "print
2.4" to see the str() behavior.

> A good compromise solution, in Ruby's case, would be to redefine
> Float#inspect such that it preserves the value's full precision without
> rounding (for round-tripping, ultimate "truth", or whatever), while leaving
> Float#to_s as it was.

Yes, that's what Python does, and what I've been proposing too. :)
And I fully agree with your reasoning there.

--
Daniel

In This Thread