4 ms·
I've seen that example before, but I don't like it. It's an example of fixed-point overflow, but it wouldn't occur in practice. It would manifest itself with 3
by PhantomGremlin 11y ago
I've seen that example before, but I don't like it. It's an example of fixed-point overflow, but it wouldn't occur in practice.
It would manifest itself with 32-bit integer indexes and with arrays of greater than 2^30 elements. So phooey. You can't even fit that many array elements into a 32-bit address space. And if you're in a 64-bit address space, you should be using 64-bit indexes.
Whine: way back in the 1960s, the IBM S/360 threw a fixed-point overflow exception (okay, to be pedantic, they called it a "program interruption", but it's the same idea) when you did that. Sadly, the Fortran compiler of the day masked it. And this same philosophy has carried over to today. About 99 times out of 100, fixed point overflow is bad, why is it being masked off?
- andrewmu 11y agoJava only allows signed 32-bit integers as array indices. It 's a compile time error to access an array with a long index (http://docs.oracle.com/javase/specs/jls/se8/html/jls-10.html#jls-10.4 http://docs.oracle.com/javase/specs/jls/se8/html/jls-10.html...).
- Alphasite_ 11y agoNot every language masks it, Swift certainly doesn't.