Division is hard, but it doesn't have to be

from blog purplesyringa's blog, | ↗ original
Developers don’t usually divide numbers all the time, but hashmaps often need to compute remainders modulo a prime. Hashmaps are really common, so fast division is useful. For instance, rolling hashes might compute u128 % u64 with a fixed divisor. Compilers just drop the ball here: fn modulo(n: u128) -> u64 { (n % 0xffffffffffffffc5) as u64 }...