Actions
Bug #9979
closedRegression: BigDecimal::ROUND_HALF_DOWN/ROUND_HALF_EVEN behave incorrectly
Bug #9979:
Regression: BigDecimal::ROUND_HALF_DOWN/ROUND_HALF_EVEN behave incorrectly
Description
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.
Updated by josephleniston (Joseph Leniston) over 12 years ago
This issue is a regression and is the same as issue #3803
Updated by nagachika (Tomoyuki Chikanaga) about 12 years ago
- Status changed from Open to Assigned
Updated by mrkn (Kenta Murata) almost 10 years ago
- 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.
Updated by jeremyevans0 (Jeremy Evans) about 7 years ago
- Status changed from Feedback to Closed
Actions