All Questions
Tagged with bitwise-operators arithmetic
4 questions
4
votes
1
answer
4k
views
Semantics of simulating a 64bit integer with two 32bit integers (hi, lo)
I am working in a system which only supports 32bit integers, in order to have a 64bit (unsigned) integer I decided to simply use two 32bit integers with one being the upper 32 bits (hi), and the other ...
2
votes
5
answers
471
views
Shortening a boolean AND with third operand
I'm trying to calculate the sum of 2 bits using basic binary arithmetic and currently, I'm doing this:
function Add(bool a, bool b, bool carry)
{
return
{
Result: a ^ b ^ carry,
...
2
votes
1
answer
992
views
Next power of 2 for a number (in search for better "bit-twiddling" way)
I just wonder if there exists better (i.e. faster?) way to get the next
power of 2 for a given number than the following one (maybe some
better sort of "bit-twiddling" hack is possible?) ...
static ...
17
votes
3
answers
65k
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 ...