From Sum to FNV-1a
32-bit hash, one character at a time

From Sum to FNV-1a

Six hash functions, each fixing one flaw of the one before. Every row shows the 32 bits of h after one operation, so you can watch how much each character actually scrambles it.

Try B =
bit is 1 bit is 0 flipped by this step differs between A and B bits that h % 32 keeps

What each step fixed

StageOrder mattersEvery character countsChange spreads to high bits
1 · sumnoyesno
2 · ORnono, bits saturateno
3 · XORnoyesno
4 · XOR, × 256yeslast 3 onlyno, just shifted
5 · FNV-1yesyesnot for the last character
6 · FNV-1ayesyesyes
For your Bloom filter

What h % 32 actually sees

Multiplication only carries changes upward: bit k of the input can change bits k and above, never below. XOR doesn't move bits at all. So in both FNV versions, the lowest 5 bits of h depend only on the lowest 5 bits of each character. 'b' (0x62) and 'B' (0x42) differ only in bit 5, so they always land in the same slot. Click aB above: many bits differ, but the slots are equal.

The fix is to fold the high bits down before taking the remainder, for example (h ^ (h >> 16)) % 32, or to use a table size that isn't a power of two, like 31, so % depends on every bit.