News for hackers. Stuff that matters.
Re:Again on 0-based vs. 1-based indexing by cbolton on Wednesday January 20, 2021 @07:58AM (#25845874)
Regarding the mathematical advantage: it depends on the subfield, but I think 1-based numbering is more common in mathematical notation and algorithms (linear algebra being a prominent example).

Regarding performance: some mentioned that the 1 offset can often be optimized away by the compiler. But even when this is not possible, common CPU architectures include instructions that can apply the offset at no extra cost, see https://stackoverflow.com/questions/28032685/is-there-a-perf... , so 1-based indexing is just as fast.

There are no comments on this comment yet.