Thread: How to code?
View Single Post
  #1494 (permalink)  
Old 12-10-2008, 06:08 PM
mladen's Avatar
mladen mladen is offline
Senior Member
 
Join Date: Oct 2006
Posts: 1,275
mladen is on a distinguished road
try this (I am assuming that c is >= 0)
PHP Code:
trade = (MathAbs(a-b) <= c); 
regards
mladen

Quote:
Originally Posted by fercan View Post
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;
}
Reply With Quote