Bit Representation & Operations
Contents
Bit Representation
Using bit operation won’t change time complexity.
positive number: the most significant bit is sign bit. 0: positive number; 1: negative number
An integer is 32 bit. java (max)int = 2^31 - 1 = 2147483647; java (max)long = 2^63 - 1
negative nunber: complements, for -1, 1 becomes inverse, and plus 1
Benefits: many CPU operations don’t need to re about signs.