[#77789] [Ruby trunk Feature#12012] Add Boolean method — prodis@...
Issue #12012 has been updated by Fernando Hamasaki de Amorim.
4 messages
2016/10/27
[ruby-core:77706] [Ruby trunk Bug#12548] Rounding modes inconsistency between round versus sprintf
From:
the.codefolio.guy@...
Date:
2016-10-21 21:30:57 UTC
List:
ruby-core #77706
Issue #12548 has been updated by Noah Gibbs.
Benoit says RubySpec PR #322 looks good. Just waiting for us to commit round-to-nearest-even mode to MRI so he can merge it. I've used [Nobu's branch](https://github.com/nobu/ruby/tree/round-to-even) locally, including to create PR #322, and it works well for me. +1
----------------------------------------
Bug #12548: Rounding modes inconsistency between round versus sprintf
https://bugs.ruby-lang.org/issues/12548#change-60987
* Author: Kieran McCusker
* Status: Open
* Priority: Normal
* Assignee:
* ruby -v: 2.4.0
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
Hi
I've found this possible bug with sprintf in our production code, but it
seems very odd that no one has reported it so I'm doubting myself.
I've tested a few versions (CRuby 2.3.1 and 2.1.9) and it was present in
both.
To reproduce in irb:
sprintf('%1.0f', 12.5)
Expected result 13 actual 12
In fact if you look at the number sequence 0.5 -> 99.5 you find the even
half will all round down and the odd half round up. 12.5.round produces the correct result (13)
If you do the same in jruby 2.2.1 you get the expected result of 13.
Many thanks
Kieran
---Files--------------------------------
round_even.patch (4.43 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>