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

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

Closed
rob99 opened this Issue Sep 7, 2013 · 3 comments

Comments

Projects
None yet
3 participants
@rob99
Copy link

rob99 commented Sep 7, 2013

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
@rob99

This comment has been minimized.

Copy link
Author

rob99 commented Sep 7, 2013

Same problems with #+

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

This comment has been minimized.

Copy link
Author

rob99 commented Sep 7, 2013

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

atambo added a commit that referenced this issue Sep 7, 2013

atambo added a commit that referenced this issue Sep 7, 2013

atambo added a commit that referenced this issue Sep 7, 2013

atambo added a commit that referenced this issue Sep 7, 2013

@ghost ghost assigned atambo Sep 7, 2013

@BanzaiMan

This comment has been minimized.

Copy link
Member

BanzaiMan commented Sep 8, 2013

I assume f87088b is the last of fixes.

@BanzaiMan BanzaiMan closed this Sep 8, 2013

atambo added a commit that referenced this issue Sep 9, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.