
I believe it's because 0.50001 isn't half, so it rounds naturally. The half-even tie break only occurs at exactly ...5 On Mon, 26 Jun 2023 at 07:39, Tomasz Smykowski via ruby-talk <ruby-talk@ml.ruby-lang.org> wrote:
Hey,
I was browsing December commit history and found a fix for round to even function being commited for special cases.
In the unit tests there were a few new tests added. One of them looks like this:
assert_equal(767573.18759, 767573.1875850001.round(5, half: :even))
Shouldn't the function round to ...8 in this case? It struck me it does not end with an even digit, but an odd one.
There are two or free unit tests that also end with odd digit.
Commit: https://github.com/ruby/ruby/commit/9f2378959e5c5b5c39c9993f1a84e5304ff113d6...
Tests: https://github.com/ruby/ruby/blob/ed587abffb48da991c33d232fd151683458938a9/t...
Cheers, Tom Smykowski ______________________________________________ ruby-talk mailing list -- ruby-talk@ml.ruby-lang.org To unsubscribe send an email to ruby-talk-leave@ml.ruby-lang.org ruby-talk info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-talk.ml.ruby-lang.org...
-- Matthew Kerwin https://matthew.kerwin.net.au/