From: "alexandruanca (Alexandru Anca) via ruby-core" Date: 2023-01-07T14:48:24+00:00 Subject: [ruby-core:111728] [Ruby master Bug#19321] BigDecimal multiplication giving different result since Ruby 3.1 Issue #19321 has been updated by alexandruanca (Alexandru Anca). > The old result was incorrect. The new, correct result is due to a bug fix. I'm going to close this. If you can find a result that is incorrect in Ruby 3.1 or 3.2, please post it. I see, makes sence. Thanks for the explanation ---------------------------------------- Bug #19321: BigDecimal multiplication giving different result since Ruby 3.1 https://bugs.ruby-lang.org/issues/19321#change-101130 * Author: alexandruanca (Alexandru Anca) * Status: Closed * Priority: Normal * ruby -v: 3.1.3 * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- I have this math operation 120.to_d * 0.07 and I noticed that since upgrading to Ruby 3.1 I get different results. I would expect to get the same result as in previous versions. ``` rbenv local 3.0.3 ��� irb require 'bigdecimal/util.rb' (120.to_d * 0.07).to_s('F') => "8.4000000000000012" ``` ``` rbenv local 3.1.3 ��� irb require 'bigdecimal/util.rb' (120.to_d * 0.07).to_s('F') => "8.4" ``` It looks like the change has been introduced in Ruby 3.1. I tested Ruby 2.7.0 and I get the same result as in 3.0 ("8.4000000000000012") I saw in the release notes that there were changes to bigdecimal so I am not sure if this is expected or it's a bug -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/