title: Comparing a floating point to one or zero with Wfloat-equal option
body: <p>I'm somewhat familiar with the issues around performing floating point equality comparisons in code.</p>
  
  <p>Currently the code base I'm compiling on <strong>(GCC, Clang)</strong> have the following option enabled: <strong>-Wfloat-equal</strong></p>
  
  <p>And in the code base there's the following example comparison:</p>
  
  <pre><code>template &lt;typename FloatType&gt;
  void foo(FloatType v) {
    if (v == FloatType(1)) {
     ...
    }
    else if (v == FloatType(0)) {
     ....
    }
  }
  </code></pre>
  
  <p>The foo function is invoked as follows:</p>
  
  <pre><code>double d = 123.98;
  float f = 123.98f;
  
  foo(d);
  foo(f);
  </code></pre>
  
  <p>Given the special case of 1 and 0 which each have exact representations in floating points <em>(double, float)</em> and where the code is clearly after an exact equality and not something that is close by some minor difference - </p>
  
  <p>Is there a way to rewrite the code such that it will not raise the associated <strong>Wfloat-equal</strong> diagnostic and will also be portable and support both float and double types?</p>