Why in C++ do static_cast<unsigned> of negative numbers differ if the number is constant or not : <p>What's the C++ rules that means <strong>equal</strong> is <em>false</em>?. Given:</p>

<pre><code>float f {-1.0};
bool equal = (static_cast&lt;unsigned&gt;(f) == static_cast&lt;unsigned&gt;(-1.0));
</code></pre>

<p>E.g. <a href="https://godbolt.org/z/fcmx2P" rel="noreferrer">https://godbolt.org/z/fcmx2P</a></p>

<pre><code>#include &lt;iostream&gt;

int main() 
{
          float   f {-1.0};
    const float  cf {-1.0};

    std::cout &lt;&lt; std::hex;
    std::cout &lt;&lt; " f" &lt;&lt; "=" &lt;&lt; static_cast&lt;unsigned&gt;(f) &lt;&lt; '\n';
    std::cout &lt;&lt; "cf" &lt;&lt; "=" &lt;&lt; static_cast&lt;unsigned&gt;(cf) &lt;&lt; '\n';

    return 0;
}
</code></pre>

<p>Produces the following output:</p>

<pre><code> f=ffffffff
cf=0
</code></pre>
