Last edited on
(delta_x > 0) and (delta_x < 0) return bool values. When you apply arithmetic operations to bools true will be treated as 1 and false as 0.
Using the conditional (ternary) operator it could have been written as:
|
int ix = (delta_x > 0 ? 1 : 0) - (delta_x < 0 ? 1 : 0)
|
Using if statements it could be rewritten as:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
int ix;
if (delta_x > 0)
{
ix = 1;
}
else if (delta_x < 0)
{
ix = -1;
}
else //delta_x == 0
{
ix = 0;
}
|
I have no idea how to write this in Pascal.
Last edited on