y = (-1 * Int((-1 * x * y) / 100)) + y0 <-- isn't a negative * negative = positive? How is this any different from the ELSE case?
Note this funky code:
if (x < 0 and y > 0) or (x > 0 and y < 0) then
y = (-1 * Int((-1 * x * y) / 100)) + y0
else
y = int(x * y / 100) + y0
end if
When I originally developed this, I could not get the same results with Python that I got with C.
It turns out that there is no consensus as to whether integer division, when one of the operands is negative, should round towards zero, negative infinity, or positive infinity.
Python and Ruby both round towards negative infinity. C rounds towards zero.
In order to get the same output from each language (to verify that each language was essentially computing the same thing and doing similar work), I had to figure out how to preclude one of the operands from being negative.
The code checks, and if either x or y is < 0 (but not both), then it multiplies by minus one to force positive division, and then by minus one again at the end to restore the sign.
And I agree, there is probably a better way to do this. But at the time, I just wanted a solution that worked, and that is what my little mind came up with.
Note that later on, I found out that Python had a integer divide operator, so there was no need to go through the hoops I did. But, since I had trouble with my "and" and "or" logic and precedence in my own interpreter, I left it in as a sort of unit test :) And, it does give whatever language is doing this more work to chew on, and more opportunities for optimization.