Results for “bit”
Small, practical examples. Search by task or narrow things down below.
Assemble a big-endian 16-bit value
Arduino / C: Cast to an unsigned 16-bit type before shifting the high byte.
Arduino / C✓ Tested
Assign a bit from a Boolean state
Arduino / C: bitWrite accepts a bit position and a zero or nonzero value.
Arduino / C✓ Tested
Calculate an integer beyond the 64-bit range
C#: Use BigInteger for arbitrary-precision integer arithmetic.
C#✓ Tested
Clear a flag without affecting neighboring bits
Arduino / C: bitClear resets only the selected bit.
Arduino / C✓ Tested
Count set bits in an unsigned integer
C: Clearing the lowest set bit on each iteration counts only one iteration per set bit.
C✓ Tested
Decode a 16-bit big-endian integer
C: Promote bytes to an unsigned integer type before combining shifted values.
C✓ Tested
Read 16-bit values from a flash table
Arduino / C: pgm_read_word retrieves a complete word from program memory.
Arduino / C✓ Tested
Require every bit in a mask
Arduino / C: Masking followed by equality tests whether all required flags are set.
Arduino / C✓ Tested
Serialize a 16-bit integer in big-endian order
C: Explicit shifts make a byte format independent of the CPU’s native byte order.
C✓ Tested
Set and clear a bit in a shell integer
Bash Scripts: Use shifts and bitwise operators for a small flag field.
Bash Scripts✓ Tested
Set and inspect a bit flag
Store several boolean states in one byte.
bitSet✓ Tested
Set and test bit flags
Use unsigned masks to combine and test C flags.
C✓ Tested