Quote:
|
Originally Posted by TheOutkastDev
Casting to less precise numeric data type causes truncation, not rounding. That's why there is a Math.Round() function.
|
That's why I add 0.5 to the value before I truncate it, it pushes x.y to (x + 1).z when y >= 0.5, thus truncating gives x + 1, and it pushes x.y to x.z when y < 0.5, thus truncating gives x.
And, yes, there is a Math.Round(), however most of his examples of code earlier were all C++, thus I gave an answer that would work in a managed or unmanaged environment.
Would you have preferred I wrote it as "round" instead of round?