I'm using the abs
built-in function to measure the difference between two numbers regardless of whether x
is bigger than y
or vice versa.
For example, if y = 5
and x = 7
, the result will be 2
. If y = 7
and x = 5
, result will still be 2
.
But if I want iterate until the result is 0
, is there a way I can use abs
or a different built-in so that y
or x
can be incremented or decremented so that the result will be 0
?
I like the abs
function, but it seems a shame to write code that has to check whether y
is bigger than x
or vice versa so as to increment or decrement until the difference is 0
.