Tag: #bitwise-operations
How do I print bits in C?
A program in C that prints the individual bits of various data types, showing how they are represented in memory. 2017-02-23
Quickly checking for a zero byte in C using bitwise operations
How to check if a 64-bit word contains a zero byte. A step-by-step example and a proof of correctness. 2017-01-24
How do I pack bits in C? (An answer using masks)
Efficient packing of game player data into 16 bits using bitwise operations on a
uint16_t
type. 2017-01-02How do I print bytes in C?
Useful to show how C represents various data types. 2016-12-22
How can I do modulo with a bitmask in C?
Use
i & (n-1)
to compute i % n
, when n
is a power of two. This avoids the modulo operation. 2016-12-10All content copyright James Fisher.