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

Closed
opan opened this Issue Apr 25, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@opan

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 from Can't compare `BigDecimal` with `Float::INFINITY` got `FloatDomainError: NaN` to Can't compare BigDecimal with Float::INFINITY got FloatDomainError: NaN Apr 25, 2017

@kares

This comment has been minimized.

Show comment
Hide comment
@kares

kares Apr 25, 2017

Member

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>'
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

This comment has been minimized.

Show comment
Hide comment
@ahorek

ahorek May 20, 2017

Contributor
BigDecimal.new(1 / 0.0, 1)

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

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

@headius headius closed this in #4618 Jun 5, 2017

@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