Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!nrl-cmf!cmcl2!brl-adm!umd5!uvaarpa!mcnc!decvax!decwrl!labrea!goose!conor From: conor@goose.UUCP (Conor Rafferty) Newsgroups: comp.lang.misc Subject: 0-based/1-based arrays Message-ID: <35@goose.UUCP> Date: 3 Mar 88 04:06:12 GMT References: <7161@sol.ARPA> <2740@mmintl.UUCP> <4343@june.cs.washington.edu> Lines: 10 Keywords: 0-based for me Summary: A concrete reason to prefer one over the other Expires: Sender: Reply-To: Followup-To: If you have a circular list of length n stored as an array, the increment-and-wrap operation on the index is 0-based 1-based i = (i+1)%n i = i%n+1 Walking with a stride of three looks like for (j = 0; j < n/3; j++) for (j = 1; j <= n/3; j++) frob( a[3*j]); frob( a[3*(j-1)+1]) In both cases the 0-based code looks more intuitive to me.