5 ms·
Any time you have a 16-bit count, it won't be enough. It's a dangerous size...
by to3m 10y ago
Any time you have a 16-bit count, it won't be enough. It's a dangerous size...
- jandrese 10y agoThe same is true of 32 bit numbers. 64 bits might finally be enough. crosses fingers
- paulddraper 10y agoWell, for counts 32 bits is enough, unless you count something really small, like every individual byte in something. And for counts 64 bits should be enough, since it's 20 billion billion.
- to3m 10y agoAssuming you managed to accumulate enough items to fill a 64-bit counter, if you got 1 core of your super-fast PC to increment a 64-bit value for each one, it would take over 100 years to count them all. (Assuming you don't just decide to pop -1 in the counter. Presumably you'd want to make sure you haven't miscounted during the accumulation phase.)
- duskwuff 10y agoFor counts of things you have in memory, 32 bits is usually enough -- even if each thing is just 8 bytes, 2^32 of those objects would require 32 GB.
- jandrese 10y ago32GB isn't an exceptional amount of memory these days.
- duskwuff 10y agoSure -- but it is an exceptional amount of memory to use for tiny objects like those. If you're working with four billion objects at a time, they're probably more substantial than eight bytes.
- detaro 10y agoOr you spent a lot of effort to get them to 8 bytes or even smaller, to fit as many of them as possible in memory. See use-cases like time-series/analytics databases, point-clouds, simulations with many elements...
- paulddraper 10y agoYou mean 4GB. And yes, 32-bit programs can't use more then 4GB.
- duskwuff 10y agoNo, I mean 32 GB -- 2^32 x 8 bytes. We're discussing 32-bit integers, not pointers.
- flashmozzg 10y agoWell, for counts 16 bits is enough, unless you count something really small, like every individual byte in something. And for counts 32 bits should be enough, since it's 4 billion. someone somewhere 20 years ago.
- munificent 10y agoYou're succumbing to selection bias[1]. You never notices all of the 16-bit counts in all of the software you use that don't overflow. For all we know, there could be a thousand of them for every case where 16 bits is too low. [1]: https://en.wikipedia.org/wiki/Selection_bias https://en.wikipedia.org/wiki/Selection_bias