From: Daniel Luz Date: 2009-03-07T10:20:20+09:00 Subject: [ruby-core:22709] Re: suggestions for float On Fri, Mar 6, 2009 at 20:52, Roger Pack wrote: > I'm thinking that for now making the default string output be one s.t. > some_float == eval("#{some_float}") > would be good [and possibly retaining the 'human readable' through > some other name, not even to be used with inspect, just something not > existing]. > Thoughts? > -=r Again, what about something like Python's? >>> str(0.1) # equivalent to Ruby's #to_s '0.1' >>> repr(0.1) # equivalent to Ruby's #inspect '0.10000000000000001' >>> print 0.1 # print casts to string, just like Ruby's puts 0.1 >>> 0.1 # the interactive interpreter uses repr, like irb 0.10000000000000001 >>> 2.1 - 3.0 -0.89999999999999991 Keeping #to_s behavior unchanged would break very little existing code, and having #inspect return something that allows reconstructing the same object is generally a very nice thing, IMO. -- Daniel