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

Can't compare BigDecimal with Float::INFINITY got FloatDomainError: NaN #4572

Closed
opan opened this issue Apr 25, 2017 · 2 comments · Fixed by #4618
Closed

Can't compare BigDecimal with Float::INFINITY got FloatDomainError: NaN #4572

opan opened this issue Apr 25, 2017 · 2 comments · Fixed by #4618

Comments

@opan
Copy link

opan commented Apr 25, 2017

JRuby version: jruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae Java HotSpot(TM) 64-Bit Server VM 25.91-b14 on 1.8.0_91-b14 +jit [darwin-x86_64]
Output uname: ruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae Java HotSpot(TM) 64-Bit Server VM 25.91-b14 on 1.8.0_91-b14 +jit [darwin-x86_64]

I'm using JRuby on Rails. I can't compare BigDecimal with Float::INFINITY.
I can do this in MRI, but not in JRuby.
Ruby MRI version: ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin15]

# MRI

BigDecimal.new(100) <= Float::INFINITY
=> true

# JRuby
BigDecimal.new(100) <= Float::INFINITY
=> FloatDomainError: NaN
	from org/jruby/ext/bigdecimal/RubyBigDecimal.java:513:in `new'
	from org/jruby/ext/bigdecimal/RubyBigDecimal.java:638:in `new'
	from org/jruby/ext/bigdecimal/RubyBigDecimal.java:1163:in `<='
	from (irb):1:in `<eval>'
	from org/jruby/RubyKernel.java:1000:in `eval'
	from org/jruby/RubyKernel.java:1298:in `loop'
	from org/jruby/RubyKernel.java:1120:in `catch'
	from org/jruby/RubyKernel.java:1120:in `catch'
	from /Users/opanmustopah/.rbenv/versions/jruby-9.1.7.0/lib/ruby/gems/shared/gems/railties-4.2.7.1/lib/rails/commands/console.rb:110:in `start'
	from /Users/opanmustopah/.rbenv/versions/jruby-9.1.7.0/lib/ruby/gems/shared/gems/railties-4.2.7.1/lib/rails/commands/console.rb:9:in `start'
	from /Users/opanmustopah/.rbenv/versions/jruby-9.1.7.0/lib/ruby/gems/shared/gems/railties-4.2.7.1/lib/rails/commands/commands_tasks.rb:68:in `console'
	from /Users/opanmustopah/.rbenv/versions/jruby-9.1.7.0/lib/ruby/gems/shared/gems/railties-4.2.7.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
	from /Users/opanmustopah/.rbenv/versions/jruby-9.1.7.0/lib/ruby/gems/shared/gems/railties-4.2.7.1/lib/rails/commands.rb:17:in `<main>'
	from org/jruby/RubyKernel.java:961:in `require'
	from bin/rails:11:in `<main>'

I think this should work too on JRuby.

Thanks in advance.

@opan opan changed the title Can't compare BigDecimal with Float::INFINITY got FloatDomainError: NaN Can't compare BigDecimal with Float::INFINITY got FloatDomainError: NaN Apr 25, 2017
@kares
Copy link
Member

kares commented Apr 25, 2017

JRuby 9.1.8.0 back-trace :

jruby-9.1.8.0 :003 > BigDecimal.new(100) <= Float::INFINITY
FloatDomainError: NaN
	from org/jruby/ext/bigdecimal/RubyBigDecimal.java:511:in `new'
	from org/jruby/ext/bigdecimal/RubyBigDecimal.java:636:in `new'
	from org/jruby/ext/bigdecimal/RubyBigDecimal.java:1161:in `<='
	from (irb):3:in `<eval>'

@ahorek
Copy link
Contributor

ahorek commented May 20, 2017

BigDecimal.new(1 / 0.0, 1)

jruby 9.1.9.0: FloatDomainError: NaN
ruby 2.2.4: FloatDomainError: NaN
ruby 2.3.4: Infinity

@kares kares added this to the JRuby 9.1.11.0 milestone Jun 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants