You can use a boolean expression that is convertible to 0
or 1
, and which has no effect when the value is 0
.
multiplies the second number by 2 if the first one was bigger
second = second + (first > second) * second;
and divides the first one by 2 if the second one was bigger.
first = first - (second > first) * (first / 2);