Quote:
Apparently, the answer to that is "it depends" (I believe mine would be the "round half up asymmetric" algorithm, as used in Java). :p The choice seems a bit arbitrary, though, since 0.5 is exactly in the middle (and so either way could be considered a correct approach), although the way you suggested is probably more consistent.
Yes, indeed. I was just going by the std::round function, which I'm pretty sure has the behaviour I described (round .5 away from zero).
Quote:
>> Multiply by 100.0, round to nearest integer, divide by 100.0
But doesn't that just truncate the value (without rounding)?
Consider 1.234. Multiply it by 100, and you get 123.4. Round this to the nearest integer; you have 123. Divide this by 100 again, and you get 1.23. I think that works, don't you? (At least in theory).