4 ms·
Fortran has the rather unusual feature that you can change the indexing to an arbitrary offset. You can declare arrays to be indexed from 0 if you want, but it
by gh02t 10y ago
Fortran has the rather unusual feature that you can change the indexing to an arbitrary offset. You can declare arrays to be indexed from 0 if you want, but it defaults to 1 and almost nobody uses this feature for obvious reasons.
- jimktrains2 10y agoBASIC did as well IIRC.
- gh02t 10y agoPascal as well I think. I dunno which was the first to support it, but it's not exactly a popular thing in modern programming.
- Extigy 10y agoI index from -N:N so that 0 is in the centre of my computational boxes.
- gh02t 10y agoYeah, something like this is the intended use, but it isn't used much at least in the Fortran I've seen. Mostly because it's really confusing for someone reading your code, as once the array is declared there's no indication what the index range is.