Friday, August 22, 2014

Bit And in Java and SQL

The Bit And compares each digits of two numbers in their binary format.

Decimal format                   Binary format
2                                        00000010
16                                      00010000
18                                      00010010

The Bit And works in the way that if two numbers both have 1 at a digit position in their binary formats, the result number has a 1 for that digit position, otherwise the result has a 0 for that digit position.

For numbers 2 and 16, since there has no position in their binary format that both numbers have 1, so the result of Bit And of 2 and 16 is 0 (00000000).

The result of Bit And of numbers 2 and 18, however, is 2 (00000010) due to the second position is 1 for both numbers.

In Java the operation symbol for Bit And is "&". For example,

             if ((theNumber & 2) == 2) {
                     . . . . . .
             }

In SQL the operation symbol for Bit And is "bitand". For example,

              SELECT name, price
              FROM fruit
              WHERE bitand (criteria, 8) = 8;

---------------------------------------------------------------------------------------------------------------

                        
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.

No comments:

Post a Comment