Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

by ikegami (Patriarch)
on Jun 23, 2009 at 15:41 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://774066]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-25 20:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found