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

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

NumberFormatException when divide BigDecimal by Float::NAN #4414

frankwong15 opened this issue Dec 28, 2016 · 2 comments
Milestone

Comments

@frankwong15
Copy link
Contributor

@frankwong15 frankwong15 commented Dec 28, 2016

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 pushed a commit to sumitmah/jruby that referenced this issue Jan 4, 2017
…tDomainError to be consistent with mri.
@headius
Copy link
Member

@headius 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
Copy link
Contributor

@seamusabshere seamusabshere commented Jan 4, 2017

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

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

[#4414] Fixes #4414. getVpValueWithPrec19 should raise FloatDomainErr…
@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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.