Bit Twiddling Hacks - Computer Graphics at Stanford University
Sign extending from a constant bit-width Sign extension is automatic for built-in types, such as chars and ints. But suppose you have a signed two's complement number, x, that is stored using only b bits. Moreover, suppose you want to convert x to an int,...