How to use approximately equal operator in objective-c?
<p>I am not sure how to do achieve this logic.</p>

<p>I have an array of numbers:</p>

<pre><code> num = @ [0,0.5,1,1.5,2...,12.5,13,13.5,14,14.5,15,15.5.....75];
</code></pre>

<p>These numbers are increased with a difference of .5</p>

<p>and I have a result number 'x'.</p>

<p>I want to find out which number in the array is the close match to the 'x' .</p>

<p>Which mathematical operator should I use ? much less &lt;&lt; ? or approximately equal ~~ operator in objective-c ?</p>

<p>I can do if <code>(x&lt;&lt;y)</code> in xcode but I cannot do <code>x ~~ y</code>. </p>

<p>At the moment I'm using the following way suggested in <a href="https://stackoverflow.com/questions/3420812/how-do-i-find-if-two-variables-are-approximately-equals">here</a>:</p>

<pre><code>static bool CloseEnoughForMe(double value1, double value2, double acceptableDifference)
{
    return fabs(value1 - value2) &lt;= acceptableDifference;
}
</code></pre>

<p>Is there any simpler method that objective-c provides ?</p>