[Issue 9717] `std.math.round` rounds away from zero instead of to the nearest even integer
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Mar 15 10:46:12 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9717
monarchdodra at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |monarchdodra at gmail.com
--- Comment #2 from monarchdodra at gmail.com 2013-03-15 10:46:11 PDT ---
(In reply to comment #1)
> Do you have an example code for this bug? I did this:
>
> void main() { writeln(std.math.round(1.4)); }
>
> and the output is 1, as expected.
I believe the "nearest even" is for the .5 tie-breakers:
EG:
round(0.5) == 0
round(1.5) == 2
round(2.5) == 2
It sounds strange at first, but it keeps things "sign agnostic" and nor shifts
the average.
http://en.wikipedia.org/wiki/Rounding#Round_half_to_even
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list