I am not sure how to do achieve this logic.
I have an array of numbers:
num = @ [0,0.5,1,1.5,2...,12.5,13,13.5,14,14.5,15,15.5.....75];
These numbers are increased with a difference of .5
and I have a result number 'x'.
I want to find out which number in the array is the close match to the 'x' .
Which mathematical operator should I use ? much less << ? or approximately equal ~~ operator in objective-c ?
I can do if (x<<y)
in xcode but I cannot do x ~~ y
.
At the moment I'm using the following way suggested in here:
static bool CloseEnoughForMe(double value1, double value2, double acceptableDifference)
{
return fabs(value1 - value2) <= acceptableDifference;
}
Is there any simpler method that objective-c provides ?