Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
March 14, 2013 [Issue 9717] New: `std.math.round` rounds away from zero instead of to the nearest even integer | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=9717 Summary: `std.math.round` rounds away from zero instead of to the nearest even integer Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: major Priority: P2 Component: Phobos AssignedTo: nobody@puremagic.com ReportedBy: verylonglogin.reg@gmail.com --- Comment #0 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2013-03-14 15:16:12 MSK --- Rounding to the nearest even integer is a default rounding mode and is an expected, useful (e.g. for mesurements rounding), and documented behaviour for `std.math.round`. But instead it currently rounds away from zero (it even uses C's `roundl`). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 15, 2013 [Issue 9717] `std.math.round` rounds away from zero instead of to the nearest even integer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis Shelomovskij | http://d.puremagic.com/issues/show_bug.cgi?id=9717 hsteoh@quickfur.ath.cx changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hsteoh@quickfur.ath.cx --- Comment #1 from hsteoh@quickfur.ath.cx 2013-03-15 10:36:32 PDT --- 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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 15, 2013 [Issue 9717] `std.math.round` rounds away from zero instead of to the nearest even integer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis Shelomovskij | http://d.puremagic.com/issues/show_bug.cgi?id=9717 monarchdodra@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |monarchdodra@gmail.com --- Comment #2 from monarchdodra@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: ------- |
March 15, 2013 [Issue 9717] `std.math.round` rounds away from zero instead of to the nearest even integer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis Shelomovskij | http://d.puremagic.com/issues/show_bug.cgi?id=9717 --- Comment #3 from monarchdodra@gmail.com 2013-03-15 10:46:50 PDT --- That said, "nearest half" is one scheme among many other. I'm not sure about "default". -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 16, 2013 [Issue 9717] `std.math.round` rounds away from zero instead of to the nearest even integer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis Shelomovskij | http://d.puremagic.com/issues/show_bug.cgi?id=9717 --- Comment #4 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2013-03-16 10:42:37 MSK --- (In reply to comment #3) > That said, "nearest half" is one scheme among many other. I'm not sure about "default". I mean the function is documented to behave this way: http://dlang.org/phobos/std_math.html#round Also I haven't seen examples where you have to use another theme but I saw ones where you have to use "half to even" theme. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation