Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
TorKlingberg
· 9y ago · 0 comments
This is fine if you are working with 32-bit numbers on a CPU with fast 64-but multiplication. What if you have 64-bit numbers?
Comments
[–]
jbapple
9y ago
x86-64 has single instruction (MUL) that produces a 128-bit unsigned result by multiplying two unsigned 64-bit operands.
[–]
gpderetta
9y ago
In addition to what jbapple said, if your hash map has more than 2^32 buckets, the latency of the division is the last of your problem.
[–]
TorKlingberg
OP
9y ago
Sure N (number of buckets) shouldn't be too big, but x (the input value) could be.
[–]
79d697i6fdif
9y ago
realistically any hash table bigger than the 32 bit boundary will be well outside any CPU caches and possibly even ram. At these sizes the memory latency will dwarf CPU speed