Re: Re: strange anomalies when using an iteration variable twice in 1 function



"Hans Heintz" <NOSPAMhh_000001@xxxxxxxxx> wrote in message
news:fdlpj19fsndiorio0r9l8iapndbq6a85ru@xxxxxxxxxx
[...]
> There's just no logic to the first of something being 0.

Yes there is. It's how many elements you have to skip to get at
the one with that index. The first index is zero.


> If there's some logic to the processor to
> it it should be the compilers problem and not the programmers.

Professor Wirth would seem to agree with you. Pascal has traditionally
started counding arrays at one; strings still show it. But for better
or worse, your programs have to run on physical processors at some
point and counting from zero on up is simply more efficient when
indexing memory.

Think of the C adagium that "A[i] = *(A+i)". The rightmost term is
really what happens in the processor, and having to add a constant
offset every time bears a real cost.

Groetjes,
Maarten Wiltink


.



Relevant Pages

  • Re: Scope of Procedures Follow-up
    ... on which Delphi is based has always encouraged programmers to use index ... Unfortunately tStrings, the ancestor of tStringList is a simple ... There is nothing wrong with using 'Offsets' when one wants to stay ... array becomes easier with zero indexes... ...
    (alt.comp.lang.borland-delphi)
  • Re: heliostat program
    ... Does QBasic assign zero to such variables in these circumstances? ... Most programmers might ... positioning while I was on a positioning job with anchors being laid ... that gave you this level of control over your code development, ...
    (comp.lang.basic.misc)
  • Re: How much is that in real money?
    ... Nobody so far has mentioned the habit of "slashing the O's". ... Surely there are some other old fart programmers around here? ... Not in my experience...if you coded "jee zero space tee zero" or "ess tee zero ...
    (alt.usage.english)
  • Re: Scope of Procedures Follow-up
    ... not really a sufficient reason to switch to it. ... Pascal actually has something like it in another way - the interface ... The first number is zero. ... If you see an index as 'the number of items to skip', the first index ...
    (alt.comp.lang.borland-delphi)
  • Re: [PATCH] Add "is_power_of_2" checking to log2.h.
    ... So says Mathematica5. ... not deal with modular arithmetic by default (which programmers very ... In fact, in modular arithmetic, zero IS a power of two. ...
    (Linux-Kernel)