Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2014-09-17 10:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (71 votes), past polls