### C Programming Bitwise Operator and Enumeration Types

**0**komentar

Bitwise Operator and Enumeration Types OBJECTIVE There are two additional ways to represent discrete values; as bits and elements in a finite set. Enumaration type s are user-defined types that allow the programmer to name a finite set with its elements, which are called enumarators. BITWISE OPERATORS AND EXPRESSIONS The bitwise operators act on integral expressions represented as strings of binary digits Bitwise Operators Logical Operators (unary) bitwise complement ~ bitwise and & bitwise exclusive or ^ bitwise inclusive or | Shift Operators left shift <<>>.

BITWISE OPERATORS AND EXPRESSIONS Bitwise Complement The operator ~ is called the one’s complement operator or the bitwise complement operator. It inverts the bit string representation of its argument; the 0’s become 1’s, and the 1’s become 0’s. int a=70707; The binary representation of a 00000000 00000001 00010100 00110011 ~a 11111111 11111110 11101011 11001100 The int value of the expression ~a is -70708. BITWISE OPERATORS AND EXPRESSIONS Two’s Complement The two’s complement representation of a nonnegative integer n is the bit string obtained by writing n in base 2. If we take the bitwise complement of the bit string and add to it 1, we obtain the two’s complement representation of –n. On a two’s complement machine, if we start with the binary representation of a negative number –n and take its bitwise complement and add 1, we obtain the two’s complement representation, or binary representation, of –n. Download free C Programming Bitwise Operator and Enumeration Types.pdf here

BITWISE OPERATORS AND EXPRESSIONS Bitwise Complement The operator ~ is called the one’s complement operator or the bitwise complement operator. It inverts the bit string representation of its argument; the 0’s become 1’s, and the 1’s become 0’s. int a=70707; The binary representation of a 00000000 00000001 00010100 00110011 ~a 11111111 11111110 11101011 11001100 The int value of the expression ~a is -70708. BITWISE OPERATORS AND EXPRESSIONS Two’s Complement The two’s complement representation of a nonnegative integer n is the bit string obtained by writing n in base 2. If we take the bitwise complement of the bit string and add to it 1, we obtain the two’s complement representation of –n. On a two’s complement machine, if we start with the binary representation of a negative number –n and take its bitwise complement and add 1, we obtain the two’s complement representation, or binary representation, of –n. Download free C Programming Bitwise Operator and Enumeration Types.pdf here

## 0 komentar:

Post a Comment