+ 4
What real life applications do bitwise operators have?
I recently learned about the bitwise operators &, |, <<, >>, and ^. Unless if we're using && or || for if statements, I haven't seen these be used in actual coding. I was wondering if learning these have any actually useful applications in real world programming.
3 ответов
+ 3
i've used them in competitive programming sometimes. ..for example
if you have a number n=7
by doing
n=n <<1; in c++ or c
it's equal to multiply the number by 2
and by using the bitwise operation you are able to see if a number is power of 2 or to calculate what is the nearest power of 2 in not many lines
+ 1
ok i made the same exaple i told you in words
Ps: insert a number when you run it
https://code.sololearn.com/cgMvOOz2N2Za/?ref=app
0
You can use dev-c++