News for hackers. Stuff that matters.
Re:Almost Always Unsigned by mjevans on Sunday January 02, 2022 @05:58AM (#29767698)
Resource 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.
Re:Almost Always Unsigned by kstenerud on Sunday January 02, 2022 @06:03AM (#29767729)
Indeed 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)