Project

General

Profile

Bug #10286

BigDecimal - inconsistency with other numeric classes

Added by Soilent (Konstantin x) almost 5 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-darwin13.0]
[ruby-core:65241]

Description

Unlike other numerical classes, BigDecimal does not raise ArgumentError when I try to parse invalid value.

require 'bigdecimal'

BigDecimal('invalid value')
# => #<BigDecimal:7fe6f9a6a058,'0.0',9(9)>

Float('invalid value')
# ArgumentError: invalid value for Float(): "invalid value"

Integer('invalid value')
# ArgumentError: invalid value for Integer(): "invalid value"

Complex('invalid value')
# ArgumentError: invalid value for convert(): "invalid value"

Rational('invalid value')
# ArgumentError: invalid value for convert(): "invalid value"

Related issues

Has duplicate Ruby master - Bug #12718: BigDecimal() should raise on invalid input, consistent with Integer() and Float()ClosedActions

History

Updated by mrkn (Kenta Murata) over 3 years ago

  • Status changed from Open to Assigned
  • Assignee set to mrkn (Kenta Murata)
#2

Updated by mrkn (Kenta Murata) almost 3 years ago

  • Has duplicate Bug #12718: BigDecimal() should raise on invalid input, consistent with Integer() and Float() added

Updated by mrkn (Kenta Murata) almost 3 years ago

  • Status changed from Assigned to Closed

This was fixed in the latest master branch of ruby/bigdecimal.

Also available in: Atom PDF