2 ms·
When I write algorithmic code based on collections, the math is usually done on offsets, not sizes. And since negative offsets don't exist, situations where the
by jltsiren 4y ago
When I write algorithmic code based on collections, the math is usually done on offsets, not sizes. And since negative offsets don't exist, situations where they could arise require explicit handling anyway.
As I work in bioinformatics, the in-memory collections tend to be pretty large. While the arithmetic is usually done with 64-bit integers, it often makes sense to store the numbers in 32 bits to save space. And since the length of a human genome is ~3 Gbp, that means unsigned 32-bit integers. Signed 32-bit integers are just bugs waiting to happen.
And sometimes the integers are stored in bit-packed arrays, where the width could be 29 bits, 33 bits, or something like that. Those are much easier and less error-prone with unsigned integers.