3 ms·
Now I'm curious what result the OP was expecting... that's how bitwise NOT should work on (IEEE 754) floating-point numbers regardless of the language, isn't it
by mrspeaker 6y ago
Now I'm curious what result the OP was expecting... that's how bitwise NOT should work on (IEEE 754) floating-point numbers regardless of the language, isn't it?
(4.2).toString(2);
> "100.00110011001100110011001100110011001100110011001101"
(~4.2).toString(2);
> "-101"
(~~4.2).toString(2);
> "100"
Perhaps the initial NOT is supposed to maintain the bits after the point? I have to go look at the spec.
[Ok, looks like that not defined in the spec, and is a language-specific behavior: I have some homework now!]
- XCSme 6y agoI think in C++ for example you can't even pass a floating number to the bitwise not operator.