Re:Faster remainders when the divisor is a constant: beating...
by thijsvandien on Friday February 08, 2019 @09:37PM
(#19120342)
For a range that small you could even build a lookup table. Or is this a case where cheap computation beats memory access?
[ Parent
| on HN ]
Re:Faster remainders when the divisor is a constant: beating...
by Const-me on Saturday February 09, 2019 @02:06AM
(#19121157)
On modern hardware, computation beats RAM access almost always.
Here's a repo with 2 tests, counting bits, and calculating sine/cosine: https://github.com/Const-me/LookupTables
Neither code is particularly cheap but still faster than RAM.
Re:Faster remainders when the divisor is a constant: beating...
by mark-r on Friday February 08, 2019 @11:33PM
(#19120746)
For modern processors you can assume that a couple of instructions will be much faster than a memory lookup. Even if the lookup is cached it will most likely push something else important out of cache.