Issue #19318 has been updated by usa (Usaku NAKAMURA).
Backport changed from 3.0: REQUIRED, 3.1: REQUIRED, 3.2: DONTNEED to 3.0: WONTFIX, 3.1:
WONTFIX, 3.2: DONTNEED
hmmm, the potential impact it could have on existing scripts, I feel like this should be
kept as a feature of sorts in stable branch...
sorry. but thanks for letting me know.
----------------------------------------
Bug #19318: Float#round rounds incorrectly for some cases
https://bugs.ruby-lang.org/issues/19318#change-103980
* Author: Eregon (Benoit Daloze)
* Status: Closed
* Priority: Normal
* Backport: 3.0: WONTFIX, 3.1: WONTFIX, 3.2: DONTNEED
----------------------------------------
This was discovered by @aardvark179.
The following spec in `spec/ruby/core/float/round_spec.rb` fails on CRuby:
```ruby
ruby_bug "", ""..."3.3" do
# These numbers are neighbouring floating point numbers round a
# precise value. They test that the rounding modes work correctly
# round that value and precision is not lost which might cause
# incorrect results.
it "does not lose precision during the rounding process" do
767573.1875850001.round(5, half: nil).should eql(767573.18759)
767573.1875850001.round(5, half: :up).should eql(767573.18759)
767573.1875850001.round(5, half: :down).should eql(767573.18759)
767573.1875850001.round(5, half: :even).should eql(767573.18759)
-767573.1875850001.round(5, half: nil).should eql(-767573.18759)
-767573.1875850001.round(5, half: :up).should eql(-767573.18759)
-767573.1875850001.round(5, half: :down).should eql(-767573.18759)
-767573.1875850001.round(5, half: :even).should eql(-767573.18759)
767573.187585.round(5, half: nil).should eql(767573.18759)
767573.187585.round(5, half: :up).should eql(767573.18759)
767573.187585.round(5, half: :down).should eql(767573.18758)
767573.187585.round(5, half: :even).should eql(767573.18758)
-767573.187585.round(5, half: nil).should eql(-767573.18759)
-767573.187585.round(5, half: :up).should eql(-767573.18759)
-767573.187585.round(5, half: :down).should eql(-767573.18758)
-767573.187585.round(5, half: :even).should eql(-767573.18758)
767573.1875849998.round(5, half: nil).should eql(767573.18758)
767573.1875849998.round(5, half: :up).should eql(767573.18758)
767573.1875849998.round(5, half: :down).should eql(767573.18758)
767573.1875849998.round(5, half: :even).should eql(767573.18758)
-767573.1875849998.round(5, half: nil).should eql(-767573.18758)
-767573.1875849998.round(5, half: :up).should eql(-767573.18758)
-767573.1875849998.round(5, half: :down).should eql(-767573.18758)
-767573.1875849998.round(5, half: :even).should eql(-767573.18758)
end
end
```
Yet this test to the best of our knowledge is correct.
This was fixed on master by @mrkn in
https://github.com/ruby/ruby/pull/7023 (thanks!).
The question is should we backport this? I think yes.
--
https://bugs.ruby-lang.org/