ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: dpulliam_ruby@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:73752] [Ruby trunk Bug#11736] Float(arg) not consistent with documentation
Date: Tue, 09 Feb 2016 17:52:50 +0000	[thread overview]
Message-ID: <redmine.journal-56938.20160209175250.09e03cdc1dfe9aac@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-11736.20151124201015@ruby-lang.org

Issue #11736 has been updated by dylan pulliam.

File 0001-Improve-documentation-on-Float-Arg.patch added
ruby -v set to ruby 2.1.5p273

I have prepared a patch for this. Let me know what you think.

----------------------------------------
Bug #11736: Float(arg) not consistent with documentation
https://bugs.ruby-lang.org/issues/11736#change-56938

* Author: Brian Wheeler
* Status: Open
* Priority: Normal
* Assignee: Zachary Scott
* ruby -v: ruby 2.1.5p273
* 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


---Files--------------------------------
0001-Improve-documentation-on-Float-Arg.patch (1.25 KB)


-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2016-02-09 17:18 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 ` dpulliam_ruby [this message]
2016-10-14  9:29 ` [ruby-core:77628] [Ruby trunk Bug#11736] " hsbt
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-56938.20160209175250.09e03cdc1dfe9aac@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).