Handling on Rational numbers inconsistent with MRI --------------------------------------------------
Key: JRUBY-2308 URL: http://jira.codehaus.org/browse/JRUBY-2308 Project: JRuby Issue Type: Bug Components: Core Classes/Modules Affects Versions: JRuby 1.1RC2 Environment: ruby 1.8.6 (2008-03-18 rev 6255) [i386-jruby1.1RC3] Reporter: Adam Byrtek Dividing Float by Rational number results in a Fixnum with JRuby and a Float with MRI . This should be consistent between platforms, I guess the MRI behavior makes more sense and JRuby should be fixed. I would be glad to help resolving this, if only some JRuby guru gives me a few tips on where to look. To reproduce try the following code require "rational" result = Float(10) / 20 puts "10.0 divided by 20 equals #{result} (#{result.class})" result = Float(10) / Rational(20) puts "10.0 divided by rational 20 equals #{result} (#{result.class})" When run with MRI this prints % ruby bug.rb 10.0 divided by 20 equals 0.5 (Float) 10.0 divided by rational 20 equals 0.5 (Float) Tested with % ruby -v ruby 1.8.5 (2006-12-25 patchlevel 12) [i686-darwin] and $ ruby -v ruby 1.8.6 (2007-06-07 patchlevel 36) [i486-linux] But when run with JRuby this prints % jruby bug.rb 10.0 divided by 20 equals 0.5 (Float) 10.0 divided by rational 20 equals 0 (Fixnum) % jruby -v bug.rb ruby 1.8.6 (2008-03-18 rev 6255) [i386-jruby1.1RC3] -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - 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