Showing posts with label Bitwise operators. Show all posts
Showing posts with label Bitwise operators. Show all posts

Wednesday, May 14, 2008

Bitwise operators

Bitwise operators

The smallest element in memory on which we are able to operate as yield is a byte; and we operate on it by use of the data type char Bitwise operator is used for manipulation of data at bit level.

These operators are used for testing the bits, shifting them right to left. Bitwise operator may not be applied to float or double data type.

This is a powerful feature of C to manipulate a bit. The programmer can access and manipulate individual bits within a piece of data.



Some of the bitwise operators in C are:

Operator Meaning
& Bitwise Logical AND
| Bitwise Logical OR
^ Bitwise Logical XOR
<< Left Shift
>> Right Shift
~ Once Compliment

Conditional & ternary operators

Conditional & ternary operators

The conditional operator? and: are sometimes called ternary operators.

A ternary operator is one which contains three operands.

The general form of ternary operator is:

exp 1 ? exp 2 : exp 3

The operator works as, if exp 1 is evaluated first. If the result is true then exp 2 is executed, otherwise exp 3 is executed.

Copyright

Copyright © 2008 C Tutorial, All rights are reserved