Avinash Haridasu wrote:Can any one tell me
how do we decide whether a number is negative or positive just by looking at the binary representation
0 0 0 0 0 0 0 1 = 1
1 1 1 1 1 1 1 1 = −1
Campbell Ritchie wrote:but you ought to remember that only applies to two's complement numbers. The char for example is unsigned and behaves differently.
Campbell Ritchie wrote:Look in the Java Language Specification and you find that the number of bits shifted is calculated % i where i is the number of bits in the datatype. So for everything except a long, shift 37 and shift 5 have the same effect.
i >> 5 is equivalent to i / 32