Bitwise Operators | C Programming Tutorial

preview_player
Показать описание


Рекомендации по теме
Комментарии
Автор

The best explanation (for me at least) i've ever heared on how the 'XOR' operator ('^') works was: »think of it as follows: if both operands were different, the bit is set, otherwise not«. as simle as that. and the key(word) to take away here is "different" ;) Very nice video by the way. Excellent job done, sir!

dejakju
Автор

The best ever video. Simple and straightforward

thebusinesschat
Автор

The best explanation out there for Bitwise Operators.

Anonymous-XY
Автор

that 's beautifully and elegantly explained. Thank you

naboulsikhalid
Автор

Love your videos so much you make hard things much easier in life!

dariabuyanovsky
Автор

Kevin, you are saving me one video at a time. Btw I took your linked list course, really helpful. I hope you'll have a DSA course!

youtubeuser
Автор

That was a really simple explanation. Thank you so much.

yousraadel
Автор

Very informative and easy to understand

simplified-code
Автор

Nice introduction. Could you make a video showing real world uses and useful tricks that you can do with bit manipulation?

Everythingzof
Автор

Is there a sequence in bitwise operation?
for e.g ((i*3) | (i*3+2)<<5)

theintelmedia
Автор

What bugs me a bit is that if r is unsigned int how do we get a signed -10 when we print the flipped version for the 9? Now I see, in the printf we can use %u instead of %d to print an unsigned int. Also it is funny that I could not find a simple way to print the binary representation. I use %b in the printf, it more or less work but always with a compilation warning.

vicsteiner
Автор

This was very helpful thank you so much !

abdelhakmezenner
Автор

Can someone explain what is happening inside the for loop that makes it able to display the bit pattern of 149.

// Given set: SET A = 149 or {7, 4, 0, 2}
#include <stdio.h>

// User-defined data type
typedef unsigned char SET; // unsigned is from 0 to 255

// Function declaration
void displayBitPattern(SET X);

int main()
{
SET A = 149;

// Function call
displayBitPattern(A);

return 0;
}

// Function definition
void displayBitPattern(SET X)
{
int bits = sizeof(SET) * 8;
int n;

for (n = bits - 1; n >= 0; n--)
{
if (X >> n & 1)
{
printf("1");
}
else
{
printf("0");
}
}
}

youtubeuser
Автор

Is there a difference between doing math with bitwise operator and arithmetic operator?

shafayet
Автор

Shouldn't the compiler complain that "r" get -10 since it's a unsigned int?

ShadowlightSE
Автор

This seems like it could be useful if you don't want to call the <math.h> library.

codingoftheuniverse