int main() { // BITWISE OPERATORS = special operators used in bit level programming // (knowing binary is important for this topic) // & = AND // | = OR // ^ = XOR // > right shift int x = 6; // 6 = 00000110 int y = 12; // 12 = 00001100 int z = 0; // 0 = 00000000 z = x & y; printf("AND = %d ", z); z = x | y; printf("OR = %d ", z); z = x ^ y; printf("XOR = %d ", z); z = x > 2; printf("SHIFT RIGHT = %d ", z); return 0; }
X is for exclusive. Think of OR as being ok with AND. 1 OR 1 = 1 1 OR 0 = 1 Because AT LEAST 1 is 1. So OR doesn't mind both being 1. 1 XOR 1 = 0 Because AT MOST should be 1. Break it into human speech and it becomes easier. True is 1 and false is 0 a XOR b = if exclusively one operand is true, return true. Else return false. AND =BOTH OR =AT LEAST 1 XOR =AT MOST 1
#include
int main()
{
// BITWISE OPERATORS = special operators used in bit level programming
// (knowing binary is important for this topic)
// & = AND
// | = OR
// ^ = XOR
// > right shift
int x = 6; // 6 = 00000110
int y = 12; // 12 = 00001100
int z = 0; // 0 = 00000000
z = x & y;
printf("AND = %d
", z);
z = x | y;
printf("OR = %d
", z);
z = x ^ y;
printf("XOR = %d
", z);
z = x > 2;
printf("SHIFT RIGHT = %d
", z);
return 0;
}
What software do you use?
@@namansalgotra6293If you are talking about where he writes the code it’s "Vs code"
This was very easy to understand and while being really descriptive, thank you so much for making that video!
Quick Note: For Shift Left, like Bro mentioned there's a pattern.....every time you shift it, it doubles.
Ex: int x = 6;
for x
thats cool
thx man
you are a legend mate! Thank you for this clear explanation!
Awesome thanks for the demo on bit wise operators, super easy to understand 👍👍👍👍
Thank you so much! Extremely clear, amazing explanations!
Thanks for the video. Very understandable, good to get me started :)
Super helpful video! Thank you!
Thanks!You made it very much easier
Thank you so much very easy to understand because of your video
Excellent! Perfect explanation!
Such a good explanation
better than a course that i bought (74.99$) on udemy...
Thank you, very clear and understandable.
you know that the udemy courses have discounts right ?
thanks bro code for the helpful tips :) and to everyone have fun programming
Bro!!!!! You are awesome and thank you
thx and great style
BIG LIKE!
Thank you for this
Masterpiece❤
So bassically 12&6 is equal to 6&12 is it?
Yes
Thanks bro
i finally know what this operators means, thanks.
Thank you so much :)
Ok cool thanks my reference book did not explain shifts very well.
Oh so those scary looking math equations are actually just logic gates and boolean algebra lol
Your a real programmer 😎
Ty :)
Thanks.
Thank you
King!
شكرا
thanks man
I'm grateful that I didn't skip binary in high school math class.
Simple yet easy to understand
What kinds of uses do these commands have?
One use is : It can be really fast for calculations
@@Abon963 so, something the compiler would automatically optimize for you?
to quickly find if a number is a power of two you can do "return n>0 and n&(n-1)"
where is ~ (complement operator)
Is it just me who noticed the text size change as the first change?
giga big coc chad thx
bruh
Why do you use %d ?
It is an format specifier it this time you know what is that....I hope you know😅😅😅😅
How to shift zero? Let's say x = 11110111 I want 11101111 (shift left) or 11111011 (shift right).
Left mate
for xor , 1 OR 1 = 1: If both bits are 1, the result is , how come 1 and 1 is zero
X is for exclusive. Think of OR as being ok with AND.
1 OR 1 = 1
1 OR 0 = 1
Because AT LEAST 1 is 1. So OR doesn't mind both being 1.
1 XOR 1 = 0 Because AT MOST should be 1. Break it into human speech and it becomes easier.
True is 1 and false is 0
a XOR b = if exclusively one operand is true, return true. Else return false.
AND =BOTH
OR =AT LEAST 1
XOR =AT MOST 1
yeah i completely forgot it
Robert
Hello
try 100
Thanks bro
Thanks bro