Top "Bit-manipulation" questions

The manipulation of individual bits.

Speed up bitstring/bit operations in Python?

I wrote a prime number generator using Sieve of Eratosthenes and Python 3.1. The code runs correctly and gracefully at 0.32 seconds …

python-3.x optimization bit-manipulation primes sieve-of-eratosthenes
Bitwise (Bitshift) operations on 64-bit integers in C++

I'm trying to deal with bitboards, which requires me to set a particular bit in a 64-bit unsigned integer. To …

c++ bit-manipulation bit-shift bitwise-or bitboard
Bitwise operations on 32-bit unsigned ints?

JavaScript converts operands to 32-bit signed ints before doing bitwise operations. It also does the operation with 32-bit signed ints, …

javascript bit-manipulation
Bitshifting in Java

I'm trying to understand how bit shift works. Can someone please explain the meaning of this line: while ((n&1)==0) …

java bit-manipulation shift
Why should I use bitwise/bitmask in PHP?

I am working on a user-role / permission system in PHP for a script. Below is a code using a bitmask …

php bit-manipulation bitmask
Swap two bits with a single operation in C?

Let's say I have a byte with six unknown values: ???1?0?? and I want to swap bits 2 and 4 (without changing any …

c arduino bit bit-manipulation
Bit parity code for odd number of bits

I am trying to find the parity of a bitstring so that it returns 1 if x has an odd # of 0…

c bit-manipulation bit parity
What's bad about shifting a 32-bit variable 32 bits?

I recently picked up a copy of Applied Cryptography by Bruce Schneier and it's been a good read. I now …

c bit-manipulation 32bit-64bit
What is the fastest way for bit operations to calculate a parity?

My solution: (for every bit of the input block, there is such a line) *parity ^= (((x[0] >> 30) & 0x00000001) * 0…

c bit-manipulation parity
PHP function flags, how?

I'm attempting to create a function with flags as its arguments but the output is always different with what's expected : …

php function bit-manipulation flags