This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Dear Smarty, In java -ive numbers are represented in twos compliment arithmetics. That is the binary representation of a number can be obtained by inverting the bit representation of the number and adding 1 to the result. Thus -3 will be represented as- 3 in binary is 00000011 now for - 3 invert the bits first which will be 11111100 now add 1 to the result. thus 11111101 this is the binary reprentation of -3 in a 8 bit format. (i took 8 bits for ease of representation). Bitwise operators are very easy to use i will tell u some basic rules of finding the results. ~x = (-x)-1 // this rule is always true thus ~3 = (-3) -1 = -4 x >>n = x/(2 power of n)// 9>>2 = 9 / (2 power 2) = 9/4 = 2; x<<n = x * (2 power of n)// Please let me know if further clarifications are required.