+ 1

Help me plz

Who can me explain the purposes, where we can use bit shifting ( << >>) and bitwise operations (&, |, ~, ^) in C

7th Oct 2024, 11:59 AM
Виталий Янчик
Виталий Янчик - avatar
3 odpowiedzi
+ 3
The purpose of bit shifting is to shift the binary values to either left or right accordingly by a specified number of positions. The bitwise operators like & is bitwise AND it will be true when both are true otherwise false. In addition | is bitwise OR it will be true when either is true otherwise false. Furthermore ~ is bitwise Not it will be true when it is false and false when true like vice versa. In conclusion ^ is bitwise XOR where when same then false and if different true. You can check out below for detailed info along with examples https://www.geeksforgeeks.org/left-shift-right-shift-operators-c-cpp/ https://www.geeksforgeeks.org/bitwise-operators-in-c-cpp/
7th Oct 2024, 1:16 PM
Aysha
Aysha - avatar
+ 1
Виталий Янчик since computers conceptually work in binary, it is self-evident that we need operators that can manipulate bits. In the Community section of Sololearn you can learn more about how and why to use the bitwise operators. https://www.sololearn.com/learn/11804/?ref=app
7th Oct 2024, 3:30 PM
Brian
Brian - avatar
0
Bitwise operations are mostly used for compiler optimizations.
7th Oct 2024, 2:04 PM
public static void