try this (I am assuming that c is >= 0)
PHP Code:
trade = (MathAbs(a-b) <= c);
regards
mladen
Quote:
Originally Posted by fercan
how do you simplify this code?
the difference between a and b <= c then trade = true, else false..
so far this is what i have made if anyone can show me a shorter way to code this..
if ( a >= b)
{
if (a - b <= c ) trade = true;
if (a - b > c) trade = false;
}
if ( a < b)
{
if (b - a <= c ) trade = true;
if (b - a > c) trade = false;
}
|