Issue Type: Bug Bug
Affects Versions: JRuby 1.7.0.pre2, JRuby 1.6
Assignee: Thomas E Enebo
Created: 12/Sep/12 9:27 AM
Description:

In MRI (several versions, including at least 1.8.7p358 and 1.9.3p194) the rounding tie breaker strategy used for floating point format strings is "round half to even", whereas in JRuby it is "round half away from zero", as can be seen in the following example code. This is different from Float#round in both implementations, which appears to adopt the "round half away from zero" strategy.

http://en.wikipedia.org/wiki/Rounding#Round_half_to_even

http://en.wikipedia.org/wiki/Rounding#Round_half_away_from_zero

MRI:

(-3...3).map{|i|f=i+0.5; [f,'%1.0f' % f,f.round]}
=> [[-2.5, "-2", -3], [-1.5, "-2", -2], [-0.5, "-0", -1], [0.5, "0", 1], [1.5, "2", 2], [2.5, "2", 3]]

JRuby:

(-3...3).map{|i|f=i+0.5; [f,'%1.0f' % f,f.round]}
=> [[-2.5, "-3", -3], [-1.5, "-2", -2], [-0.5, "-1", -1], [0.5, "1", 1], [1.5, "2", 2], [2.5, "3", 3]]

Project: JRuby
Priority: Minor Minor
Reporter: Ben Armstrong
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
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

Reply via email to