>>10986999Actually the formula rounds negative mm umbers down (that is to say, it rounds their absolute values up) what isn't what people usually mean by rounding (what's this? Intel 8086 arithmetics?)
Any way, replace +0.5 to +sgn(x)0.5 to get the correct rounding for all reals.
Also forgoing the 0.5 entirely makes it a floor and forgoing the 0.5 and making the sum start at 0 turns it into the ceiling function