Many of the languages such as Java, C++, and Python have the flexibility of providing Boolean types which can be set to either TRUE or FALSE. Here we will be learing about it keeping in mind the python for data science view of it.
Let’s consider a program that uses Logical Not (or !) operator on Boolean.
The example above is an expected one. But what will happen if we have not used Bitwise Not ( or ~) operator before? Let’s see through an example.
The bitwise not operator ~ gives the complement of a number. So, 0 becomes 1, and vice versa. As we know, Boolean TRUE and FALSE values have values 1 and 0, respectively.
As it returns the inverse, so, TRUE will return inverse of 1 and FALSE will return inverse of 0.
Java- Java has no such function to attach ~ operator to Boolean values.
So, we can say that “Logical Not or !” is for Boolean values and “bitwise not or~” for integers. C/C++ and Python are into auto-promotion of Boolean to integer types when an integer operator is applied. But Java does no such thing.