Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

With 1-based indexing, length == last index.

Does 0-based indexing have any advantage, beyond ability to do pointer arithmetic with indexes?



In 0-based indexing, n % length is a value inside the range.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: