CSE 230 Study Guide - Final Guide: Inline-Four Engine, Exclusive Or, C Data Types
Document Summary
2"s complement notation: positive values have 0 in left-most bit, to negate a positive value, complement ( flip ) each bit and then add 1 to the result. (negative values have 1 in the left-most bit. , example: Bitwise operators bitwise complement (1"s complement) bitwise and bitwise or bitwise xor (exclusive or) left shift right shift. = 0x5678, c = 0x9abc; short int printf( %x\n%x\n%x\n%x\n%x\n , ~a, a & b, a | b, a ^ b, a & b | c); Shift operators short int unsigned short printf( %x\n%x\n%x\n%x\n , a = 0x1234, Masking: the bitwise-and operator is often used to mask out specific bits of an integer value, example: int is_odd(int num) int mask = _______; return (________________); } data compression: bitwise operators can be used to pack data and unpack data, pack - store small data units in large unit, unpack - extract small data units from large unit.