mirror of
https://github.com/zeux/pugixml.git
synced 2025-01-15 02:17:56 +08:00
Added round_nearest_nzero explanation
git-svn-id: http://pugixml.googlecode.com/svn/trunk@462 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
parent
f262cbb6be
commit
d3419f2f4b
@ -444,6 +444,7 @@ namespace
|
|||||||
double round_nearest_nzero(double value)
|
double round_nearest_nzero(double value)
|
||||||
{
|
{
|
||||||
// same as round_nearest, but returns -0 for [-0.5, -0]
|
// same as round_nearest, but returns -0 for [-0.5, -0]
|
||||||
|
// ceil is used to differentiate between +0 and -0 (we return -0 for [-0.5, -0] and +0 for +0)
|
||||||
return (value >= -0.5 && value <= 0) ? ceil(value) : floor(value + 0.5);
|
return (value >= -0.5 && value <= 0) ? ceil(value) : floor(value + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user