0
What is the practical use of bitwise operator or operations in python?
I don't get it what is the use of converting integers to binary code and operate them? I mean give example where they are usefull
6 Answers
+ 2
For example i&1 returns whether i is odd or even and is much more faster than i%2, which does the same and is more often used.
-(~i)) adds 1 to 1
In generall they are one of the most fastest operations one can do and almost every other operation you want to do can be done with them if you also use bitwise shifting!
https://en.m.wikipedia.org/wiki/Bitwise_operation
+ 4
https://www.sololearn.com/post/23827/?ref=app
+ 1
They are called "bitwise" operators. So if u need more information about individual bits with in a value then probably they are suitable.
0
Thank you Alexander Thiem very helpful!
It's all clear now!
0
you are welcome! Then you could also add a solved tag in your question....