Issue Type: Bug Bug
Affects Versions: JRuby 1.7.2
Assignee: Thomas E Enebo
Components: Ruby 1.9.3
Created: 16/Feb/13 3:36 PM
Description:

Hi guys,

it looks like dividing any BigDecimal by a Float between 0 and 1 results in Infinity:

 
hk@hk:~$ rvm 1.7.2 do ruby -rbigdecimal -e "puts(BigDecimal('1') / 0.5)"
Infinity
hk@hk:~$ rvm 1.9.3 do ruby -rbigdecimal -e "puts(BigDecimal('1') / 0.5)"
0.2E1
hk@hk:~$ 

hk@hk:~$ rvm info

jruby-1.7.2:

  system:
    uname:       "Linux hk 3.5.0-23-generic #35-Ubuntu SMP Thu Jan 24 13:15:40 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux"
    system:      "ubuntu/12.10/x86_64"
    bash:        "/bin/bash => GNU bash, Version 4.2.37(1)-release (x86_64-pc-linux-gnu)"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.18.6 (stable) by Wayne E. Seguin <wayneeseg...@gmail.com>, Michal Papis <mpa...@gmail.com> [https://rvm.io/]"
    updated:      "1 day 3 hours 6 minutes 21 seconds ago"

  ruby:
    interpreter:  "jruby"
    version:      "1.7.2"
    date:         "jruby 1.7.2 (1.9.3p327) 2013-02-11 fffffff on Java HotSpot(TM) 64-Bit Server VM 1.7.0_13-b20 [linux-amd64]"
    platform:     "linux-amd64"
    patchlevel:   "TM"
    full_version: "jruby 1.7.2 (1.9.3p327) 2013-02-11 fffffff on Java HotSpot(TM) 64-Bit Server VM 1.7.0_13-b20 [linux-amd64]"

  homes:
    gem:          "/home/hk/.rvm/gems/jruby-1.7.2"
    ruby:         "/home/hk/.rvm/rubies/jruby-1.7.2"

  binaries:
    ruby:         "/home/hk/.rvm/rubies/jruby-1.7.2/bin/ruby"
    irb:          "/home/hk/.rvm/rubies/jruby-1.7.2/bin/irb"
    gem:          "/home/hk/.rvm/rubies/jruby-1.7.2/bin/gem"
    rake:         "/home/hk/.rvm/gems/jruby-1.7.2/bin/rake"

  environment:
    PATH:         "/home/hk/.rvm/gems/jruby-1.7.2/bin:/home/hk/.rvm/gems/jruby-1.7.2@global/bin:/home/hk/.rvm/rubies/jruby-1.7.2/bin:/home/hk/.rvm/bin:/home/hk/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
    GEM_HOME:     "/home/hk/.rvm/gems/jruby-1.7.2"
    GEM_PATH:     "/home/hk/.rvm/gems/jruby-1.7.2:/home/hk/.rvm/gems/jruby-1.7.2@global"
    MY_RUBY_HOME: "/home/hk/.rvm/rubies/jruby-1.7.2"
    IRBRC:        "/home/hk/.rvm/rubies/jruby-1.7.2/.irbrc"
    RUBYOPT:      ""
    gemset:       ""


hk@hk:~$ 

And dividing a BigDecimal("0") by such a float results in NaN:

 
hk@hk:~$ rvm   1.7.2 do ruby -rbigdecimal -e "puts(BigDecimal('0') / 0.5)"
NaN

This happens only in 1.9 mode:

 
hk@hk:~$ rvm 1.7.2 do jruby --1.8 -rbigdecimal -e "puts(BigDecimal('1') / 0.5)"
2.0
hk@hk:~$ rvm 1.7.2 do jruby --1.9 -rbigdecimal -e "puts(BigDecimal('1') / 0.5)"
Infinity

And it worked in 1.6.8:

 
hk@hk:~$ rvm 1.6.8 do jruby --1.9 -rbigdecimal -e "puts(BigDecimal('1') / 0.5)"
2.0

Digging a bit further I found out the following: Dividing using .div with 0 digits works:

 
hk@hk:~$ rvm 1.7.2 do jruby -rbigdecimal -e "puts(BigDecimal('1').div(0.5))"
2

But with more than 0 digits it crashes like this:

 
hk@hk:~$ rvm 1.7.2 do jruby --1.9 -rbigdecimal -e "puts(BigDecimal('1').div(0.5,1))"
RubyBigDecimal.java:1138:in `op_div19': java.lang.NullPointerException
	from RubyBigDecimal$INVOKER$i$op_div19.gen:-1:in `call'
	from CachingCallSite.java:346:in `cacheAndCall'
	from CachingCallSite.java:204:in `call'
	from -e:1:in `__file__'
	from -e:-1:in `load'
	from Ruby.java:810:in `runScript'
	from Ruby.java:803:in `runScript'
	from Ruby.java:674:in `runNormally'
	from Ruby.java:523:in `runFromMain'
	from Main.java:390:in `doRunFromMain'
	from Main.java:279:in `internalRun'
	from Main.java:221:in `run'
	from Main.java:201:in `main'

This also works in 1.8 mode:

 
hk@hk:~$ rvm 1.7.2 do jruby --1.8 -rbigdecimal -e "puts(BigDecimal('1').div(0.5,1))"
2.0

Plase keep up the good work and thank you very much for any hints on that,
Heiko Seebach

Environment: Linux
Project: JRuby
Priority: Critical Critical
Reporter: Heiko Seebach
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira
--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Reply via email to