Learn the method
(x ≠ 0) ∧ (y ≠ 0)8-bit word · arithmetic wraps modulo 256| Operator | Bits 7 → 0 | Decimal |
|---|---|---|
x | 0000 00012 | 1 |
y | 0000 00112 | 3 |
Result | 0000 00012 | 1 |
Logical AND asks whether both values are nonzero. The result is 1, not a bitwise combination.
#include <stdint.h>
uint8_t x = 1;
uint8_t y = 3;
uint8_t result = x && y;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.7, §2.1.9