title: C++ Compare 2 Floats to another float
body: <p>I have the following question.  Let's say I've got 3 float values:</p>
  <pre><code>float1 = 300.00;
  float2 = 200.00;
  float3 = 100.00;
  </code></pre>
  <p>Now I want to determine which of the two floats (float2 &amp; float3) is closer to float1 and then return a true or false.</p>
  <pre><code>if closercheck(float1, float2, float3) //Example Code
  {
      console.write(&quot;float2 is nearer to float1&quot;);
  }
  else
  {
      console.write(&quot;float3 is nearer to float1&quot;);
  }
  </code></pre>
  <p>So the output would be:</p>
  <blockquote>
  <p>float 2 is nearer to float 1</p>
  </blockquote>
  <p>Now my question is, how could I code the &quot;closercheck()&quot; function?</p>
  <p>I know how to check which of the 2 floats is closer to zero: <code>(abs(float2) &lt; abs(float3))</code>.</p>
  <p>But I don't know how to compare 2 floats to another float.</p>