Re:Why do arrays start at 0?
by dahart on Wednesday August 24, 2022 @08:01PM
(#32587552)
The well known “Numerical Recipes in C 2nd ed.” talks about how the first edition promoted exactly this - offset the pointer after allocation and you can use any indexing origin you want. And they promoted 1-indexing and wrote all the algorithms as such, before switching everything to 0-indexing for the 2nd edition.
I agree with you the subtraction instruction is not exorbitant, especially considering malloc is much more expensive and always has been.
I agree with you the subtraction instruction is not exorbitant, especially considering malloc is much more expensive and always has been.