oracle / truffleruby

A high performance implementation of the Ruby programming language, built on GraalVM.
https://www.graalvm.org/ruby/
Other
3.02k stars 185 forks source link

Kernel#sprintf('%.2f') is not accurate like Ruby 2.4+ #1511

Closed deepj closed 2 years ago

deepj commented 5 years ago

Since Ruby 2.4, sprintf('%.2f') returns a different accuracy.

MRI (2.5.3)

sprintf('%.2f', '1.025')
# => "1.02"

TruffleRuby (1.0.0-rc10)

sprintf('%.2f', '1.025')
# => "1.03"
chrisseaton commented 5 years ago

It's not inaccurate - it's rounding incorrectly.

andrykonchin commented 2 years ago

Fixed in c99ec964fb51f8364c6919467e898db6969f4058. Thank you for reporting.