Certain numbers are not correctly rounded in number_with_precision. For instance: 31.125 with precision 2 should be 31.13, but number_with_precision returns 31.12.
These test are added and fail on a system with ruby 1.8.4 (2005-12-24) [i686-darwin8.7.1]:
assert_equal("31.13", number_with_precision(31.125, 2))
assert_equal("8.13", number_with_precision(8.125, 2))
This is seemingly due to a problem with sprintf in Ruby. Calling printf "%01.2f" 31.825 in the OSX Terminal correctly returns 31.83
On the other hand in irb: sprintf "%01.2f", 31.825 returns "31.82"
The same erroneous behavior has been observed on a windows machine in cygwin when calling printf in a terminal windows with GNU Bash.
This error also causes the bug in ticket #8027.
--
( copenhagen.rb rails patch day )