From: hsbt@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:77628] [Ruby trunk Bug#11736] Float(arg) not consistent with documentation
Date: Fri, 14 Oct 2016 09:29:54 +0000 [thread overview]
Message-ID: <redmine.journal-60898.20161014092953.c205a7875a5d19da@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-11736.20151124201015@ruby-lang.org
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/
next prev parent reply other threads:[~2016-10-14 8:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-11736.20151124201015@ruby-lang.org>
2015-11-24 20:10 ` [ruby-core:71661] [Ruby trunk - Bug #11736] [Open] Float(arg) not consistent with documentation bwheeler96
2015-12-07 7:43 ` [ruby-core:71889] [Ruby trunk - Bug #11736] " ko1
2016-02-09 17:52 ` [ruby-core:73752] [Ruby trunk Bug#11736] " dpulliam_ruby
2016-10-14 9:29 ` hsbt [this message]
2016-10-27 7:27 ` [ruby-core:77776] " usa
2016-11-11 16:06 ` [ruby-core:78089] " nagachika00
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-60898.20161014092953.c205a7875a5d19da@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).