Project

General

Profile

Actions

Feature #2152

closed

Split functionality of Float#inspect and Float#to_s

Added by rogerdpack (Roger Pack) over 14 years ago. Updated over 6 years ago.

Status:
Closed
Target version:
[ruby-core:25820]

Description

=begin
Reposting here as a feature request.

As a side note, I think I figured out why the confusion occured in posting the original--if one navigates to "feature requests" then click "new issue" it defaults to a Bug report, even though you were browsing feature requests.

============Proposal=============
Currently the Float#to_s and Float#inspect return an "accurate" representation of the internal float, to help alert users of floating point inconsistencies.

This is better than the old way. Some have recently pointed out that the old functionality has been lost [the old "pretty float" style]. This is surprising to them.

In order to have 1.9.2 add functionality and not also lose the old, I propose to split the function of Float#inspect and Float#to_s thus:

String#to_s will be the pretty way
and
String#inspect will be the more accurate way.

With this in place, in irb users are notified of inaccuracies, and it is less surprising.

I'm not totally set on using those method names--the proposal is that both be available somewhere.

Thanks!
-r
=end


Files

add_float_inspect.diff (2.17 KB) add_float_inspect.diff rogerdpack (Roger Pack), 03/26/2010 05:25 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0