Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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 meditating upon the Monastery: (8)
As of 2016-10-27 19:48 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (370 votes). Check out past polls.