0.0 == -0.0 (On x86)
memcmp of doubles containing 0.0 and -0.0 does not return 0. And if
I recall correctly, two NaNs will compare as not equal, but would
(could?) memcmp as equal.
On Fri, Nov 27, 2026 at 10:57 AM Александр Поваляев via Std-Proposals
<std-proposals@lists.isocpp.org> wrote:
>
> Hi Sebastian,
>
> Why a bitwise comparison is inapplicable for a case when float or double is being used as a "Key" unordered_set template argument?
>
> Let's say, we have got a hash<float> function which uses all the bits of the float value and CompPred which does the same. It will work without any error. My attitude is the same: you either use bitwise comparison and bitwise hash function, or you use a class comparison operator (operator ==). In case of erroneous padding bits or some pointers, a class comparison operator is needed.
>
>
> пт, 27 нояб. 2026 г. в 12:18, Sebastian Wittmeier via Std-Proposals <std-proposals@lists.isocpp.org>:
>>
>> And even that salient part would have to be normalized (for a planned bitwise compare) for some data formats, which allow non-unique representations of the same value. And even then it may be application-dependent. E.g. is a positive 0 equal to a negative 0?
>>
>>
>>
>> So even float or double as types perhaps used for the representation of the salient part, the bitwise comparison may be unapplicable.
>>
>>
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Jonathan Wakely via Std-Proposals <std-proposals@lists.isocpp.org>
>> (An alternative design would be to have a projection function which just gives you the salient parts of the object, so you would call proj(obj) which would return const A&, and you could hash that and compare that for equality. But we don't have that design either.)
>>
>> --
>> Std-Proposals mailing list
>> Std-Proposals@lists.isocpp.org
>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
> --
> Std-Proposals mailing list
> Std-Proposals@lists.isocpp.org
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals