Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NumberFormatException when divide BigDecimal by Float::NAN #4414

frankwong15 opened this issue Dec 28, 2016 · 2 comments

NumberFormatException when divide BigDecimal by Float::NAN #4414

frankwong15 opened this issue Dec 28, 2016 · 2 comments


Copy link


jruby (2.3.1) 2016-11-09 0150a76 Java HotSpot(TM) 64-Bit Server VM 25.111-b14 on 1.8.0_111-b14 +jit [linux-x86_64]
Linux frank-nb 4.4.0-57-generic #78-Ubuntu SMP Fri Dec 9 23:50:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Expected Behavior

MRI ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]

$ ruby -e "require 'bigdecimal'; BigDecimal('1') / Float::NAN"
-e:1:in `to_r': NaN (FloatDomainError)
	from -e:1:in `/'
	from -e:1:in `<main>'

Actual Behavior

$ jruby -e "require 'bigdecimal'; BigDecimal('1') / Float::NAN"
Unhandled Java exception: java.lang.NumberFormatException
java.lang.NumberFormatException: null
                <init> at java/math/
                <init> at java/math/
                <init> at java/math/
               valueOf at java/math/
  getVpValueWithPrec19 at org/jruby/ext/bigdecimal/
          getVpValue19 at org/jruby/ext/bigdecimal/
           op_quo19_20 at org/jruby/ext/bigdecimal/
              op_quo20 at org/jruby/ext/bigdecimal/
                  call at org/jruby/ext/bigdecimal/RubyBigDecimal$INVOKER$i$1$0$op_quo20.gen:-1
          cacheAndCall at org/jruby/runtime/callsite/
                  call at org/jruby/runtime/callsite/
     invokeOther4:\=\| at -e:1
                <main> at -e:1
   invokeWithArguments at java/lang/invoke/
                  load at org/jruby/ir/
             runScript at org/jruby/
           runNormally at org/jruby/
           runNormally at org/jruby/
           runFromMain at org/jruby/
         doRunFromMain at org/jruby/
           internalRun at org/jruby/
                   run at org/jruby/
                  main at org/jruby/
sumitmah pushed a commit to sumitmah/jruby that referenced this issue Jan 4, 2017
…tDomainError to be consistent with mri.
Copy link

headius commented Jan 4, 2017

@seamusabshere Looks like you're working on a patch? I've ported little bits of this logic from C's not too hard. Main challenge is figuring out where the Ruby-specific logic ends and the BigDecimal logic begins.

Copy link

hi @headius, nice to hear from you! i think you were trying to @-mention @frankwong15 :)

@enebo enebo closed this as completed in 22ef041 Jan 5, 2017
enebo added a commit that referenced this issue Jan 5, 2017

[#4414] Fixes #4414. getVpValueWithPrec19 should raise FloatDomainErr…
@enebo enebo added this to the JRuby milestone Jan 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

4 participants