From: muraken@... Date: 2016-11-21T15:54:59+00:00 Subject: [ruby-core:78235] [Ruby trunk Bug#9979][Feedback] Regression: BigDecimal::ROUND_HALF_DOWN/ROUND_HALF_EVEN behave incorrectly Issue #9979 has been updated by Kenta Murata. Status changed from Assigned to Feedback I think the current behavior is the correct one. ``` $ ruby -rbigdecimal -ve 'p Gem::Dependency.new("bigdecimal").to_spec.version.to_s; puts ("0.50"..."0.60").map {|x| [x, BigDecimal(x).round(0, BigDecimal::ROUND_HALF_DOWN).to_s("F")].join(" -> ") }' ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15] "1.2.8" 0.50 -> 0.0 0.51 -> 1.0 0.52 -> 1.0 0.53 -> 1.0 0.54 -> 1.0 0.55 -> 1.0 0.56 -> 1.0 0.57 -> 1.0 0.58 -> 1.0 0.59 -> 1.0 $ ruby -rbigdecimal -ve 'p Gem::Dependency.new("bigdecimal").to_spec.version.to_s; puts ("0.50"..."0.60").map {|x| [x, BigDecimal(x).round(0, BigDecimal::ROUND_HALF_EVEN).to_s("F")].join(" -> ") }' ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15] "1.2.8" 0.50 -> 0.0 0.51 -> 1.0 0.52 -> 1.0 0.53 -> 1.0 0.54 -> 1.0 0.55 -> 1.0 0.56 -> 1.0 0.57 -> 1.0 0.58 -> 1.0 0.59 -> 1.0 $ ruby -rbigdecimal -ve 'p Gem::Dependency.new("bigdecimal").to_spec.version.to_s; puts ("1.50"..."1.60").map {|x| [x, BigDecimal(x).round(0, BigDecimal::ROUND_HALF_EVEN).to_s("F")].join(" -> ") }' ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15] "1.2.8" 1.50 -> 2.0 1.51 -> 2.0 1.52 -> 2.0 1.53 -> 2.0 1.54 -> 2.0 1.55 -> 2.0 1.56 -> 2.0 1.57 -> 2.0 1.58 -> 2.0 1.59 -> 2.0 ``` Joseph, please show the wrong examples. ---------------------------------------- Bug #9979: Regression: BigDecimal::ROUND_HALF_DOWN/ROUND_HALF_EVEN behave incorrectly https://bugs.ruby-lang.org/issues/9979#change-61604 * Author: Joseph Leniston * Status: Feedback * Priority: Normal * Assignee: Kenta Murata * ruby -v: 2.1.2 * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- The incorrect behaviour is that all fractional values between 0.5 (inclusive) and 0.6 (non-inclusive) are subject to the rounding policy for 'half', whereas it should only be applied for fractional values exactly equal to 0.5. -- https://bugs.ruby-lang.org/ Unsubscribe: