Range#step with Float arguments differs from MRI ------------------------------------------------
Key: JRUBY-6133 URL: https://jira.codehaus.org/browse/JRUBY-6133 Project: JRuby Issue Type: Bug Environment: --1.9 Reporter: Martin Harriman Assignee: Thomas E Enebo Range#step in MRI uses multiplication to step a floating-point value. Range#step in jruby uses repeated addition, which has significantly poorer error behavior and results in different values and even different numbers of iterations when compared with MRI. For example: {noformat} 1.0...55.6.step(18.2).to_a {noformat} In MRI, the result is a four-element array, with the final element just an epsilon less than 55.6. In jruby 1.7.0, the result is a three element array, terminating at 37.4. As a rule of thumb, strength-reducing floating-point multiplication into repeated floating-point addition is a bad idea, as you will get much larger quantization error with the repeated addition (and it is not usually faster than floating-point multiplication). -- This message is automatically generated by JIRA. 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