Float#divmod is incorrect is some cases
---------------------------------------
Key: JRUBY-1930
URL: http://jira.codehaus.org/browse/JRUBY-1930
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.1RC1
Environment: Latest JRuby 1.1RC1, built from trunk.
Reporter: Vladimir Sizikov
Attachments: float-divmod.patch
Consider the following example:
{noformat}
p "DIV: #{0.58.div(1/12.0)}"
p "MOD: #{0.58.modulo(1/12.0)}"
p "DIVMOD: #{0.58.divmod(1/12.0).inspect}"
{noformat}
MRI prints:
"DIV: 6"
"MOD: 0.08"
"DIVMOD: [6, 0.08]"
JRuby prints:
"DIV: 6"
"MOD: 0.07999999999999999"
"DIVMOD: [5, 0.07999999999999999]"
Note that divmod returns *FIVE* instead of 6.
It seems that the similar problem has been reported against MRI, and fixed
there:
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=14540&group_id=426
This also leads to rubinius spec failure:
Numeric#divmod divmod right floats FAILED
Expected 5 to equal 6:
./mspec/expectations.rb:10:in `fail_with'
./mspec/matchers/base.rb:8:in `=='
/opt/work/rubinius/./spec/ruby/1.8/core/numeric/divmod_spec.rb:31
/opt/work/rubinius/./spec/ruby/1.8/core/numeric/divmod_spec.rb:25:in `call'
./mspec/runner/runner.rb:136:in `describe'
./mspec/runner/runner.rb:135:in `each'
./mspec/runner/runner.rb:130:in `describe'
./mspec/runner/runner.rb:135:in `describe'
/opt/work/rubinius/./spec/ruby/1.8/core/numeric/divmod_spec.rb:9
/opt/work/rubinius/./spec/ruby/1.8/core/numeric/divmod_spec.rb:9:in `load'
tmp/last_mspec.rb:15
tmp/last_mspec.rb:10:in `each'
tmp/last_mspec.rb:10
The proposed patch (with regression tests), fixes the problem, and the spec
failure.
--
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