Knowledge Walls
Venkatesan
Hyderabad, Andhra Pradesh, India
Passcode:
Introduction [cont'd]
Input Output Functions [cont'd]
Structures and Unions [cont'd]
# Preprocessor [cont'd]
Bitwise operators in Operators of Programming in C
1644 Views
Bitwise operators 
Bitwise operators are operates the values bit level. Also performs shift left and shift right in the bit level. It is not applicable for float and double. Binary values are performs the operator actionas in bit level.
What is bit level 
All values stores in the memory as binary value. Binary values are 0 and 1. int datatype allocates 2 bytes. 2 bytes is 16 bits. so integer allocates 16 bit memory. For example if value is 14 then binary value is 1110 stores in the memory as below.
0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0
Operators and meaning 
Operators Meaning
& Bitwise AND
| Bitwise OR
^ Bitwise exclusive OR
<< Shift the values by bit level left side
>> Shift the values by bit level right side
Program Hints 
a value is 14. 14 equal binary value is 1110. 1110 move to the right side include one more zero at right side then the binary value is 11100. 11100 equal decimal value is 28.
0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0
a<<1 shift 1 bit left side
0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0
Program
#include "stdio.h"
void main(){
    int a = 14;
    a = a<<1;
    printf("%d",a);
}
Output 
A = 28
Next Topics
Next lessons of current book.
Input Output Functions of Programming in C
Input Output Functions of Programming in C
Input Output Functions of Programming in C
Best Lessons of "Programming in C"
Top lessons which are viewed more times.
Structures and Unions of Programming in C
Input Output Functions of Programming in C
Structures and Unions of Programming in C
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.