News for hackers. Stuff that matters.
Re:The definitive guide to “modulo bias” and how to avoid it... by kelnos on Thursday September 15, 2022 @03:06PM (#32856993)
Isn't that why most tutorials on writing hash tables that use this bucketing method recommend using table sizes that are powers of two? I guess most tutorials don't exactly explain why, though, so someone who doesn't understand could decide to not use a power of two without understanding why that's bad.
Re:The definitive guide to “modulo bias” and how to avoid it... by xxpor on Thursday September 15, 2022 @04:46PM (#32858216)
There's another reason why (mathematically related) to use a power of 2 as well: it makes the modulo a simple and fast mask, instead of a slow division.