ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:82512] [Ruby trunk Bug#13848] BigDecimal.new('200.') raises an exception
       [not found] <redmine.issue-13848.20170829122454@ruby-lang.org>
@ 2017-08-29 12:24 ` ded
  2017-08-29 17:23 ` [ruby-core:82514] " shevegen
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: ded @ 2017-08-29 12:24 UTC (permalink / raw)
  To: ruby-core

Issue #13848 has been reported by ddoherty03 (Daniel Doherty).

----------------------------------------
Bug #13848: BigDecimal.new('200.') raises an exception
https://bugs.ruby-lang.org/issues/13848

* Author: ddoherty03 (Daniel Doherty)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
BigDecimal.new('200.') raises an exception:

ArgumentError: invalid value for BigDecimal(): "200."

It should accept this as a valid decimal number.

This requires fixing numbers read in from the wild.



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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:82514] [Ruby trunk Bug#13848] BigDecimal.new('200.') raises an exception
       [not found] <redmine.issue-13848.20170829122454@ruby-lang.org>
  2017-08-29 12:24 ` [ruby-core:82512] [Ruby trunk Bug#13848] BigDecimal.new('200.') raises an exception ded
@ 2017-08-29 17:23 ` shevegen
  2017-08-30 11:21 ` [ruby-core:82534] " ded
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: shevegen @ 2017-08-29 17:23 UTC (permalink / raw)
  To: ruby-core

Issue #13848 has been updated by shevegen (Robert A. Heiler).


I believe you mean for BigDecimal.new('200.') to be equivalent to BigDecimal.new('200.0')?

I could see both ways be ok; there may be use cases where the error is better because of
the user not being explicit enough; or the user does not want to have to type in the
trailing '0'. So I can't say whether this is really a bug or not, it may be specifically
wanted to be that way.

I guess if there are no trade offs though, then I'd agree with the proposal if you meant
that it is the same to mean for a trailing '0' there - but I could also see for purity
to require the '0' to be passed.

What about input such as:

    BigDecimal.new('0.')

I mean it will be 0 anyway... it reads strangely to omit the the '0' to my eyes though ...

Latest docu can be found here, if anyone else is interested:

  https://ruby-doc.org/stdlib/libdoc/bigdecimal/rdoc/BigDecimal.html


----------------------------------------
Bug #13848: BigDecimal.new('200.') raises an exception
https://bugs.ruby-lang.org/issues/13848#change-66324

* Author: ddoherty03 (Daniel Doherty)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
BigDecimal.new('200.') raises an exception:

ArgumentError: invalid value for BigDecimal(): "200."

It should accept this as a valid decimal number.

This requires fixing numbers read in from the wild.



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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:82534] [Ruby trunk Bug#13848] BigDecimal.new('200.') raises an exception
       [not found] <redmine.issue-13848.20170829122454@ruby-lang.org>
  2017-08-29 12:24 ` [ruby-core:82512] [Ruby trunk Bug#13848] BigDecimal.new('200.') raises an exception ded
  2017-08-29 17:23 ` [ruby-core:82514] " shevegen
@ 2017-08-30 11:21 ` ded
  2017-09-07  0:26 ` [ruby-core:82686] " xkernigh
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: ded @ 2017-08-30 11:21 UTC (permalink / raw)
  To: ruby-core

Issue #13848 has been updated by ddoherty03 (Daniel Doherty).


Robert, yes, I think it should be the same as BigDecimal.new('200.').  The problem arises, not when a programmer is typing the number---requiring a programmer to be explicit is OK by me---but when strings are processed that come from a user of the code.

ss = '200.' # Read from a user-prepared file.
BigDecimal.new(ss) => ArgumentError ...

As it is, the programmer has to massage every string to recognize a reasonable, albeit a bit sloppy, string that is clearly meant as a valid number.

Regards,


----------------------------------------
Bug #13848: BigDecimal.new('200.') raises an exception
https://bugs.ruby-lang.org/issues/13848#change-66343

* Author: ddoherty03 (Daniel Doherty)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
BigDecimal.new('200.') raises an exception:

ArgumentError: invalid value for BigDecimal(): "200."

It should accept this as a valid decimal number.

This requires fixing numbers read in from the wild.



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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:82686] [Ruby trunk Bug#13848] BigDecimal.new('200.') raises an exception
       [not found] <redmine.issue-13848.20170829122454@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2017-08-30 11:21 ` [ruby-core:82534] " ded
@ 2017-09-07  0:26 ` xkernigh
  2017-12-13 15:26 ` [ruby-core:84237] [Ruby trunk Bug#13848][Assigned] " muraken
  2018-12-07  2:24 ` [ruby-core:90352] [Ruby trunk Bug#13848][Closed] " muraken
  5 siblings, 0 replies; 6+ messages in thread
From: xkernigh @ 2017-09-07  0:26 UTC (permalink / raw)
  To: ruby-core

Issue #13848 has been updated by kernigh (George Koehler).


`Float('200.')` also raises ArgumentError. In this way, BigDecimal.new seems consistent with Float. But it's strange that `Float('200hello world')` raises ArgumentError but `BigDecimal.new('200hello world')` succeeds.

----------------------------------------
Bug #13848: BigDecimal.new('200.') raises an exception
https://bugs.ruby-lang.org/issues/13848#change-66520

* Author: ddoherty03 (Daniel Doherty)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
BigDecimal.new('200.') raises an exception:

ArgumentError: invalid value for BigDecimal(): "200."

It should accept this as a valid decimal number.

This requires fixing numbers read in from the wild.



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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:84237] [Ruby trunk Bug#13848][Assigned] BigDecimal.new('200.') raises an exception
       [not found] <redmine.issue-13848.20170829122454@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2017-09-07  0:26 ` [ruby-core:82686] " xkernigh
@ 2017-12-13 15:26 ` muraken
  2018-12-07  2:24 ` [ruby-core:90352] [Ruby trunk Bug#13848][Closed] " muraken
  5 siblings, 0 replies; 6+ messages in thread
From: muraken @ 2017-12-13 15:26 UTC (permalink / raw)
  To: ruby-core

Issue #13848 has been updated by mrkn (Kenta Murata).

Status changed from Open to Assigned
Assignee set to mrkn (Kenta Murata)
Target version set to next minor

I'm working this bug at https://github.com/ruby/bigdecimal/pull/87

----------------------------------------
Bug #13848: BigDecimal.new('200.') raises an exception
https://bugs.ruby-lang.org/issues/13848#change-68365

* Author: ddoherty03 (Daniel Doherty)
* Status: Assigned
* Priority: Normal
* Assignee: mrkn (Kenta Murata)
* Target version: next minor
* ruby -v: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
BigDecimal.new('200.') raises an exception:

ArgumentError: invalid value for BigDecimal(): "200."

It should accept this as a valid decimal number.

This requires fixing numbers read in from the wild.



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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:90352] [Ruby trunk Bug#13848][Closed] BigDecimal.new('200.') raises an exception
       [not found] <redmine.issue-13848.20170829122454@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2017-12-13 15:26 ` [ruby-core:84237] [Ruby trunk Bug#13848][Assigned] " muraken
@ 2018-12-07  2:24 ` muraken
  5 siblings, 0 replies; 6+ messages in thread
From: muraken @ 2018-12-07  2:24 UTC (permalink / raw)
  To: ruby-core

Issue #13848 has been updated by mrkn (Kenta Murata).

Status changed from Assigned to Closed

Fixed in r66222

----------------------------------------
Bug #13848: BigDecimal.new('200.') raises an exception
https://bugs.ruby-lang.org/issues/13848#change-75463

* Author: ddoherty03 (Daniel Doherty)
* Status: Closed
* Priority: Normal
* Assignee: mrkn (Kenta Murata)
* Target version: 
* ruby -v: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
BigDecimal.new('200.') raises an exception:

ArgumentError: invalid value for BigDecimal(): "200."

It should accept this as a valid decimal number.

This requires fixing numbers read in from the wild.



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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-12-07  2:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-13848.20170829122454@ruby-lang.org>
2017-08-29 12:24 ` [ruby-core:82512] [Ruby trunk Bug#13848] BigDecimal.new('200.') raises an exception ded
2017-08-29 17:23 ` [ruby-core:82514] " shevegen
2017-08-30 11:21 ` [ruby-core:82534] " ded
2017-09-07  0:26 ` [ruby-core:82686] " xkernigh
2017-12-13 15:26 ` [ruby-core:84237] [Ruby trunk Bug#13848][Assigned] " muraken
2018-12-07  2:24 ` [ruby-core:90352] [Ruby trunk Bug#13848][Closed] " muraken

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).