What do these operator do exactly
int m=5;
int n=4;
k= m&n;
or
K = m|n;
thx
What do these operator do exactly
int m=5;
int n=4;
k= m&n;
or
K = m|n;
thx
Those are bitwise binary operators.
The operator | is the logical or. Definition: x or y is 1 iff one of them or both are 1.
The operator & is the logical and. Definition: x and y is 1 iff both are 1.
Thanx
But could you tell me that in lamance nubee terms
for m=5 and n=4
In binary:
m = 0101
n = 0100
Apply &- and |-operation using the definition:
So in decimal:Code:m n m|n 0 0 0 1 1 1 0 0 0 1 0 1 m n m&n 0 0 0 1 1 1 0 0 0 1 0 0
m | n = 5
m & n = 4
There are some more bitwise operators, read this thread for more info:
http://www.cprogramming.com/cboard/s...wise+operators
Last edited by Shiro; 05-25-2002 at 08:04 AM.
Thanx really appreciated. Got a c exam 2morrow so just going through a few things
Thanx again shaun
Sorry to bug you again but what if they where changed
from m||n
and m&&n
The operators || and && are relational operators and no binary operators.
(A || B) is 1 if (A > 0) or (B > 0), else 0.
(A && B) is 1 if (A > 0) and (B > 0), else 0.
Note that A and B are not necessarily bits, they can also be of type int, char etc.