Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: why the array index has to start at 0??

by ikegami (Pope)
on Jun 23, 2009 at 15:41 UTC ( #774066=note: print w/ replies, xml ) Need Help??

in reply to why the array index has to start at 0??

In N bits, an integer can represent 2^N indexes starting at zero. If you start at index 1, you'll only be able to access 2^N-1 indexes. Using 1-based indexes therefore requires indexes twice as big and requires more code to support the same array sizes. This was not a luxury that could be afforded.

This may not be the case anymore, but you can't ignore how it's been done for ages, and there are many other good reasons as you've seen throughout this thread.

Comment on Re: why the array index has to start at 0??

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://774066]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2015-10-07 02:56 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (170 votes), past polls