Learn the method
x → base 28-bit word · arithmetic wraps modulo 256| Operator | Bits 7 → 0 | Decimal |
|---|---|---|
x | 1001 10012 | 153 |
Result | 1001 10012 | 153 |
128 + 16 + 8 + 1 = 153
The set positions add up to 153. Its binary representation is 10011001.
#include <stdint.h>
#include <stdio.h>
uint8_t x = 153;
for (int bit = 7; bit >= 0; --bit)
putchar('0' + ((x >> bit) & 1));C17 · snippets use uint8_t from <stdint.h>. Casts keep the low 8 bits; shifts use unsigned operands. Run the statements inside a function.
CS:APP · §2.1.1, §2.2.2