Re: 0-based Indexing

new topic     » goto parent     » topic index » view thread      » older message » newer message

----- Original Message ----- 
From: "C. K. Lester" <cklester at yahoo.com>
To: "EUforum" <EUforum at topica.com>
Subject: 0-based Indexing


> 
> 
> I don't get it. Why do some languages use 0-based indexing? It's got to be
> the dumbest thing in programming language history. Or maybe not.
> 
Well, not so dumb. It really is a performance issue for CPUs. It comes from the
world of RAM addresses. The index is actually an offset from an address. In other
words, what number do you need to add to an address, to get to the start of the
first byte that the address references - the answer is zero. Thus the 'index' to
the first byte is zero, to the second byte is one, etc... Although this becomes
second nature to mathamatically inclined people, it is not so intutitve for
regular people's way of thinking. That is, the first element is 'named' #1, the
second is named #2, etc ...

-- 
Derek

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu