Skip to main content

Practice ยท 3 of 5

Deliberate Wraparound

CHALLENGE
Difficulty: advanced+25 XP

Implement unsigned int fnv1a_step(unsigned int h, unsigned char byte) โ€” one FNV-1a round: h ^= byte; h *= 16777619u. Unsigned overflow is *defined* modular arithmetic; this hash depends on it. Then implement int mod16(int x) returning x mod 16 for non-negative x using only unsigned reasoning (no % on negative signed values).

Back to lesson: Practice: UB and Optimizer Drills