NumberFormatException when divide BigDecimal by Float::NAN #4414

Closed
frankwong15 opened this Issue Dec 28, 2016 · 2 comments

Projects

None yet

4 participants

@frankwong15

Environment

jruby 9.1.6.0 (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/BigDecimal.java:494
                <init> at java/math/BigDecimal.java:383
                <init> at java/math/BigDecimal.java:806
               valueOf at java/math/BigDecimal.java:1274
  getVpValueWithPrec19 at org/jruby/ext/bigdecimal/RubyBigDecimal.java:446
          getVpValue19 at org/jruby/ext/bigdecimal/RubyBigDecimal.java:424
           op_quo19_20 at org/jruby/ext/bigdecimal/RubyBigDecimal.java:1024
              op_quo20 at org/jruby/ext/bigdecimal/RubyBigDecimal.java:1020
                  call at org/jruby/ext/bigdecimal/RubyBigDecimal$INVOKER$i$1$0$op_quo20.gen:-1
          cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:338
                  call at org/jruby/runtime/callsite/CachingCallSite.java:163
     invokeOther4:\=\| at -e:1
                <main> at -e:1
   invokeWithArguments at java/lang/invoke/MethodHandle.java:627
                  load at org/jruby/ir/Compiler.java:111
             runScript at org/jruby/Ruby.java:846
           runNormally at org/jruby/Ruby.java:761
           runNormally at org/jruby/Ruby.java:779
           runFromMain at org/jruby/Ruby.java:592
         doRunFromMain at org/jruby/Main.java:425
           internalRun at org/jruby/Main.java:313
                   run at org/jruby/Main.java:242
                  main at org/jruby/Main.java:204
@sumitmah sumitmah pushed a commit to sumitmah/jruby that referenced this issue Jan 4, 2017
Sumit M [#4414] Fixes #4414. getVpValueWithPrec19 should raise FloatDomainErr…
…or to be consistent with mri.
6a6dc24
@sumitmah sumitmah pushed a commit to sumitmah/jruby that referenced this issue Jan 4, 2017
Sumit M [#4414] Fixes #4414. getVpValueWithPrec19 should raise FloatDomainErr…
…or to be consistent with mri.
22ef041
@headius
Member
headius commented Jan 4, 2017

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

@seamusabshere
Contributor

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

@enebo enebo pushed a commit that closed this issue Jan 5, 2017
Sumit M [#4414] Fixes #4414. getVpValueWithPrec19 should raise FloatDomainErr…
…or to be consistent with mri.
22ef041
@enebo enebo closed this in 22ef041 Jan 5, 2017
@enebo enebo added this to the JRuby 9.1.7.0 milestone Jan 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment