Skip to content
This repository

BigDecimal#* returns Float (should be BigDecimal) #992

Closed
rob99 opened this Issue · 3 comments

3 participants

Robert Brown Hiro Asari Alex Tambellini
Robert Brown

MRI:

$ ruby -v 
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin11.4.2]
$ ruby -e 'require "bigdecimal";puts (BigDecimal.new(10) * 0.456).class'
BigDecimal

Using JRuby 1.7.4:

$ jruby -v
jruby 1.7.4 (1.9.3p392) 2013-05-16 2390d3b on Java HotSpot(TM) 64-Bit Server VM 1.6.0_51-b11-457-11M4509 [darwin-x86_64]
$ jruby -e 'require "bigdecimal";puts (BigDecimal.new(10) * 0.456).class'
Float

Using JRuby 1.7.5 dev:

    $ java -jar jruby-complete-1.7.5.dev.jar -e 'require "bigdecimal";puts (BigDecimal.new(10) * 0.456).class'
    Float
    $ java -jar jruby-complete-1.7.5.dev.jar -v
    jruby 1.7.5.dev (1.9.3p392) 2013-09-06 294934d on Java HotSpot(TM) 64-Bit Server VM 1.6.0_51-b11-457-11M4509 [darwin-x86_64]

Fixnum appears to be ok:

$ jruby -e 'require "bigdecimal";puts (BigDecimal.new(10) * 9).class'
BigDecimal

Rational not so much:

# 1.7.4
$ jruby -e 'require "bigdecimal";puts (BigDecimal.new(10) * Rational(2,3)).class'
NilClass
$ java -jar jruby-complete-1.7.5.dev.jar -e 'require "bigdecimal";puts (BigDecimal.new(10) * Rational(2,3)).class'
NilClass
Robert Brown

Same problems with #+

$ ruby -e 'require "bigdecimal";puts (BigDecimal.new(10) + 0.123).class'
Float
Robert Brown

Error with #/(rational)

$ jruby -e 'require "bigdecimal";puts (BigDecimal.new(10) / Rational(2,3)).class'
ArgumentError: Rational can't be coerced into BigDecimal without a precision
   / at org/jruby/ext/bigdecimal/RubyBigDecimal.java:1057
 (root) at -e:1

Also

$ jruby -e 'require "bigdecimal";puts (BigDecimal.new(10) + Rational(2,3)).class'
TypeError: Rational can't be coerced into BigDecimal
   + at org/jruby/ext/bigdecimal/RubyBigDecimal.java:906
 (root) at -e:1
Hiro Asari
Owner

I assume f87088b is the last of fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.