The bitwise-operators tag has no wiki summary.
31
votes
2answers
1k views
Why do bitwise operators have lower priority than comparisons?
Could someone explain the rationale, why in a bunch of most popular languages (see note below) comparison operators (==, !=, <, >, <=, >=) have higher priority than bitwise operators (&, |, ...
7
votes
2answers
261 views
Using scoped enums for bit flags in C++
An enum X : int (C#) or enum class X : int (C++11) is a type that has a hidden inner field of int that can hold any value. In addition, a number of predefined constants of X are defined on the enum. ...
0
votes
2answers
149 views
What kind of specific projects can I do to master bitwise operations in C++? Also is there a canonical book? [closed]
I don't use C++ or bitwise operations at my current job but I'm thinking of applying to companies where it is a requirement to be fluent with them (on their tests anyway).
So my question is: Can ...
0
votes
3answers
993 views
Is there something special about the number 65535?
2¹⁶-1 & 2⁵ = 2⁵ (or? obviously ?)
A developer asked me today what is bitwise 65535 & 32 i.e. 2¹⁶-1 & 2⁵ = ?
I thought at first spontaneously 32 but it seemed to easy whereupon I thought ...
18
votes
15answers
2k views
What are bit operators good for?
Programming languages often come with various bit operators (e.g. bitwise left- and right shift, bitwise AND, OR, XOR...). These don't get used though very much, or at least such has my experience ...
-2
votes
2answers
671 views
Flipping the desired bit of an integer number
Suppose you were given an integer number in decimal notation. This when represented in binary will be a series of 0's and 1's. This sequence varies in length with the magnitude of the number. Now ...
4
votes
3answers
1k views
Ternary operator (condition ? foo : bar) and the XOR (^) operator
I have read in a recent code review that both ternary operator (condition ? foo : bar) and the XOR operator ^ are rarely used in Java. Is it true?
If yes, is this because they are less readable? or ...
5
votes
3answers
404 views
How does bit flipping / complementing work?
I am currently learning about bitwise operation, so bear with me. I understand AND, OR, and shifting. What I don't understand is bit flipping.
So, 5 is 0101. When someone says to me "flip those", it ...
13
votes
5answers
1k views
Importance of bitwise thinking
I take interview for my company. During interview I've faced many candidates having 1 to 3 years of experience in their field. Typically, they had experience in C#, Java, J2ME, iOS and similar ...
10
votes
5answers
2k views
What are the advantages of using bitwise operations?
Following reading the latest CodeProject newsletter, I came across this article on bitwise operations. It makes for interesting reading, and I can certainly see the benefit of checking if an integer ...
11
votes
5answers
1k views
What is the benefit of studying bitwise operators?
What is the benefit of studying bitwise operators (Bitwise Not, Bitwise AND, Bitwise OR, Bitwise XOR, Left Shift, Signed Right Shift, Unsigned Right Shift etc.)?
Will we really use these operators in ...
27
votes
13answers
2k views
How good does a well-rounded programmer need to be with bit-wise operations? [closed]
I have been browsing some OpenJDK code recently and have found some intriguing pieces of code there that has to do with bit-wise operations. I even asked a question about it on StackOverflow.
...
4
votes
3answers
202 views
How about multiple bits performance in common databases?
If there are 20 bit columns (non-null boolean), is it better to explicitly hold them in an integer type (int32)? Or, will the underlying database merge them in a single integer?
I'm using PostgreSQL, ...
11
votes
4answers
3k views
What's your favorite bit-wise technique? [closed]
A few days ago, StackExchange member Anto inquired about valid uses for bit-wise operators. I stated that shifting was faster than multiplying and dividing integers by powers of two. StackExchange ...