2 ms·
Yup, and that's a case of an API not aging well. But even in that case, switching to unsigned is only kicking the can down the road, not solving the problem. Yo
by kstenerud 5y ago
Yup, and that's a case of an API not aging well. But even in that case, switching to unsigned is only kicking the can down the road, not solving the problem. You'd get another year or two and then hit the 4294967295 limit.
As for 64-bit values, unless you can foresee requiring > 8 quintillion, unsigned isn't buying you anything.
- mjevans 5y agoResource consumption does matter though. For example CPU caches or the quantity of RAM within a system. If their workset does fit within 32 bits of index the intentional design choice very likely correlates to a measurable improvement in speed due to cache locality and system resource utilization.
- kstenerud 5y agoIndeed it does matter! As I said this is an example of an API that hasn't aged well (when they devised it, they probably didn't envision this happening). There are a number of ways to handle this: - Use unsigned 32-bit (gives you a little bit more runway, but you'll still hit the end hard) - Use 64-bit values (ends your problem once and for all, but costs double the memory so now you have a new problem) - Use 40-bit values (Gives you a lot more runway, but costs CPU)