-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPRO9.C
90 lines (82 loc) · 2.69 KB
/
PRO9.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/***************
BITWISE OPERATORS
*******************************/
#include<stdio.h>
int main()
{
int a=8,b=10;
// this is the & = bitwise AND OPERATOR
/*->& (AND)
BITWISE OPERATOR WORK ON THE BITS NOT THE VALUE
*/
/**********************************************************************
* -> &(AND operator)
* its bitwise OR operator 1=true 0=False
* A B A|B
* 1 1 1
* 1 0 0
* 0 1 0
* 0 0 0
************************************************************************/
/*-------------------------------------------------------
*
* 8= 01000
* 10= 01010
* -------------
* 8 <-01000
* ------------------------------------------------------*/
printf("8&10=%d",a&b);
/**********************************************************************
* -> | (OR operator)
* its bitwise OR operator 1=true 0=False
* A B A|B
* 1 1 1
* 1 0 1
* 0 1 1
* 0 0 0
************************************************************************/
/*-------------------------------------------------------
*
* 8= 01000
* 10= 01010
* -------------
* 10<-01010
* ------------------------------------------------------*/
printf("\n8|10=%d\n",a|b);
/**********************************************************************
* -> ~ (Not operator)
* its bitwise not operator 1=true 0=False
* A ~A
* 1 0
* 0 1
*************************************************************************/
/*-------------------------------------------------------
*
* 8= 0 1000 //Extremly left bit is sign bit its represent the sign
* ~8=1 0111 =7
* 1=1 0001
* --------------
* 9<-1 1001 if sign bit is 1 that means its negative value
*------------------------------------------------------*/
printf("~8=%d",~a);
/**********************************************************************
* -> ^ (XOR operator)
* its XOR operator 1=true 0=False
* 8 = 1000
* ^10= 1010
* 0010
*******************************************************************/
printf("\n8^10=%d",a^b);
/**********************************************************************
* -> >> (rightshift operator)
* its bitwise rightshift operator 1=true 0=False
* 8>>1 = 1000>>1 result is 4=0100
*******************************************************************/
printf("\n8>>1=%d",a>>1);
/**********************************************************************
* -> << (leftshift operator)
* its bitwise leftshift operator 1=true 0=False
* 8<<1 = 1000<<1 result is 16=10000
*******************************************************************/
printf("\n8<<1=%d",a<<1);
}