[#77789] [Ruby trunk Feature#12012] Add Boolean method — prodis@...
Issue #12012 has been updated by Fernando Hamasaki de Amorim.
4 messages
2016/10/27
[ruby-core:77628] [Ruby trunk Bug#11736] Float(arg) not consistent with documentation
From:
hsbt@...
Date:
2016-10-14 09:29:54 UTC
List:
ruby-core #77628
Issue #11736 has been updated by Hiroshi SHIBATA.
Assignee changed from Zachary Scott to Hiroshi SHIBATA
Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.1: UNKNOWN, 2.2: REQUIRED, 2.3: REQUIRED
----------------------------------------
Bug #11736: Float(arg) not consistent with documentation
https://bugs.ruby-lang.org/issues/11736#change-60898
* Author: Brian Wheeler
* Status: Closed
* Priority: Normal
* Assignee: Hiroshi SHIBATA
* ruby -v: ruby 2.1.5p273
* Backport: 2.1: UNKNOWN, 2.2: REQUIRED, 2.3: REQUIRED
----------------------------------------
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
---Files--------------------------------
0001-Improve-documentation-on-Float-Arg.patch (1.25 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>