← Back to context

Comment by Ygg2

4 months ago

Maths books aren't being weird. They are counting in a way most people learn to count. One apple, two apples, three apples. You don't start zeroth apple, one apple, two apples, then respond the set of apple contains three apples.

But computers are not actually counting array elements, it's more accurate to compare array indexing with distance measurement. The pointer (memory address) puts you at the start of the array, so the first element is right there under your feet (i.e. index 0). The other elements are found by measuring how far away from the start they are:

  element_position = start + index*element_size

  • > But computers are not actually counting array elements

    Sure. But from most general to least general, it goes:

    Counting on fingers >>>> Math Equations >> Computer algorithms

    The more general ones influence the less general ones because that's where most people start.