4 ms·
I can see how in a higher-level language it might make sense to use 1-based indices. this is, after all, how humans typically count. I just don't agree with it
by leetcrew 6y ago
I can see how in a higher-level language it might make sense to use 1-based indices. this is, after all, how humans typically count. I just don't agree with it as a general statement over all programming languages. in low-level contexts where you are working directly with memory, it is quite natural for indices (or idx * element_size) to be equivalent to offsets.
- kaba0 6y agoDepending on the context of the program, both can be more comfortable. Pointers/enumerators? 0-based Heavy math problem? 1-based I believe there is a few languages which can let you set it