It turns out that all the above mentioned examples were run on the x86 architecture, and for FPU it has the following rule:
When it comes to the operation of a floating-point operation, it is a rule (see Tables 8-10 and 11-1), the result is commonly known as the QNaN FP Indefinite (Section 4.8.3.7).
Taken from Intel® 64 and IA-32 Architectures Software Developer's Manual Volume 1: Basic Architecture Section 4.8.3.5.
Looking at the table specified in the quote above, we find there the following operation, which gives the output QNaN:
Division: ∞ by ∞; 0 by 0.
Those. just what we have in question (there are other operations there). And if we look at table 4-3, from section 4.2.2, we see that in QNaN the sign bit is set to 1, which explains the appearance of negative NaN in the output.
And if you look at it all from the point of view of language, you get an indefinite behavior, so we can see anything.
C ++ 14, [expr] p4:
It is not clear.
The answer is inspired by a wonderful post from Raymond Chen.
+0/-0in JS? - user207618