Now that i've a) had some
coffee, and b) done a little research, here's what i've found..
the algorithm should be "floor(x + 0.5"). "floor" is the operation that says "take the largest integer LESS THAN or equal to the value in question. there is a similar function called "ceiling", which is the smallest number greated than or equal to the number in question. there are good examples here:
Floor/Ceiling examples so..
x=-2.4 => -2.4+0.5 = -1.9 => floor(-1.9)=-2. (-1 is not less than -1.9, -2 is!!!).
x=-2.5=>-2.5 + 0.5=-2 => floor(-2)=-2. this again works.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors