From: ko1@... Date: 2015-12-07T07:43:10+00:00 Subject: [ruby-core:71889] [Ruby trunk - Bug #11736] Float(arg) not consistent with documentation Issue #11736 has been updated by Koichi Sasada. Description updated Assignee set to Zachary Scott Document is wrong. Zack, could you fix it? ---------------------------------------- Bug #11736: Float(arg) not consistent with documentation https://bugs.ruby-lang.org/issues/11736#change-55295 * Author: Brian Wheeler * Status: Open * Priority: Normal * Assignee: Zachary Scott * ruby -v: * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- Float(arg) ��� float Returns arg converted to a float. Numeric types are converted directly, the rest are converted using arg.to_f. Converting nil generates a TypeError. Strings are NOT converted using arg.to_f ~~~ '123_INVALID'.to_f # => 123.0 ~~~ ~~~ Float('123_INVALID') # => ArgumentError ~~~ This could be fixed by changing object.c like so: ~~~ - return DBL2NUM(rb_str_to_dbl(val, TRUE)); + return DBL2NUM(rb_str_to_dbl(val, FALSE)); ~~~ But it appears that this is desired behavior as there are many specs to ensure this strict validity checking. Please update the documentation to reflect this. Thanks, Brian -- https://bugs.ruby-lang.org/