In Java, the bitwise not operator (~
) inverts all bits of an integer or long. But why is this not possible for a double
? Is there any method of using this operation on a double
? I am writing my own programming language in Java (this is NOT a homework assignment), and I believe that bitwise should be included for doubles.
Any ways of using bitwise not on doubles?
EDIT: This is not a duplicate of How to perform a bitwise operation on floating point numbers, because I am using Java as opposed to the discussed C. I also know that there is no possible way using the syntax of the language, but the answers there seem to cast the double
to an int
. I need to keep the double as it is, without changing it to an int
or long
.
EDIT: The bitwise not isn't what I thought it would be. It seems to perform *-1 - 1
on the input. Therefore, my question now becomes:
I wish to turn a double into binary (see my other question ), invert all of the bits (0 to 1 and 1 to 0), then convert it back to a double.