Re: Why do programmers start counting from 0?

From: Timothy J. Bruce <uniblab_at_hotmail.com>
Date: Sun, 12 Dec 2004 00:00:09 GMT
Message-ID: <dSLud.925$925.97879_at_news1.epix.net>


<timothychung_at_gmail.com> reported confusion > One day, I started wondering why we start counting from 0 Here is the answer why PROGRAMMERS start counting at zero: <snip>
U1R2 EQU 0xF2
U2R1 EQU 0xE1
U2L1 EQU 0xDF
U1L2 EQU 0xEE
D1L2 EQU 0x0E
D2L1 EQU 0x1F
D2R1 EQU 0x21
D1R2 EQU 0x12
MoveRose: DB U1R2, U2R1, U2L1, U1L2, D1L2, D2L1, D2R1, D1R2 MoveRoseCount: EQU 0x08
...
MOV SI, MoveRose
MOV AX, SI
; AX now points to the first element of the MoveRose array,
; AX = SI + 0

INC AX
; AX now points to the second element of the array,
; AX = SI + 1

INC AX
; AX now points to the third element of the array,
; AX = SI + 2

MOV SI, AX
MOV DL, [SI]
; DL now holds the value 0xDF because that is the third element of the
MoveRose array,
; [MoveRose + 2]

</snip>

Mathematicians start counting at zero because is typically the root of the integer domain...
Z = {0, -1, 1, -2, 2, -3, 3, ... , -n, n, ... } ...and often included in the positive integer domain... Z+ = {0, 1, 2, 3, ... }

Normal people start counting at one because they were told Counting Numbers (those you can count on your fingers) don't include zero, and start with one, and end with ten, and learn it as an ordered-list... C = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

HTH,
Timothy J. Bruce
uniblab_at_hotmail.com
</RANT> Received on Sun Dec 12 2004 - 01:00:09 CET

Original text of this message