3 ms·
I can usually get away with visualizing indices as being just before a memory cell (i.e. on the boundary between cells), whereas lengths are spans of cells. For
by smaddox 8y ago
I can usually get away with visualizing indices as being just before a memory cell (i.e. on the boundary between cells), whereas lengths are spans of cells. For example:
| H | e | l | l | o |
Index 0 1 2 3 4 5
Length |<--------5-------->|
This makes it easy to visualize that 1-based indexing has indices centered on the memory cell, so calculating a span requires reducing the subtractor by 1.