I’d just like to contribute my two-cents to this discussion: coming from high energy physics, where quantities frequently span many, many orders of magnitude, I nevertheless have found this to be a complete non-issue (for 64 bit integers). The main reason, I suppose, and as others have pointed out, is that typically data with such large magnitudes are handled as floats.
This is sort of an interesting information-theoretic/thermodynamic question to think about. The only reason to use ints instead of floats (I think) is precision and it seems to me there are some deep, fundamental reasons (i.e. related to the renormalization group) why you wouldn’t want the type of precision offered by ints in situations where you have values spanning so many orders of magnitude. I suppose there might be some special cases where you are dealing with accumulating lots of small values to make a bigger value (if you have some sort of “\infty\epsilon”) where this might be relevant, but I would think that in such a case the right thing to do would be to use BigFloat
or something like it, and even in that case, it’s pretty hard for me to contrive a good example (I’ve written quite a lot of numerical integration code in my lifetime, and still, this has never been an issue).
(Come to think of it, if I ever did see any code where this was relevant in a physics context, it would serve to me as a red flag that whatever the code is doing involves a theory that is badly fine-tuned. Of course, sometimes fine-tuning is something that we just have to live with, probably because we don’t understand what’s really going on (ironically it’s a problem that I’m much more tolerant of than a lot of people), but on purely theoretical grounds, I would find any application of code that needs this type of overflow checking as a bit suspicious.)
I suppose it’s possible that I’m completely missing the point and there is some (completely different) application of this sort of thing that I’m just not thinking of.
That said, I’m a bit curious, is there some specific application where you expect this to be particularly relevant?
Edit: The one major exception to the above discussion I can think of is pure number theory (and by extension cryptography, which seems like a very relevant application). However, these seem like really special cases, and I don’t think it’d be unreasonable to expect number-theory/crypto people to use some sort of overflow-checking macros where appropriate.