Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
This arises from how the basic "machine" (the hardware) works.

Let's say that you have an array of 3 "things" starting at address "4". I am going to make a simplifying assumption here that each "thing" fits within the native "word size" of the hardware machine. So what is the machine address of the first thing in the array? It is address 4+0 (it is at address 4). What it the address of the 2nd thing? That is address 5=4+1, etc..

Some languages will do an index-1 for you automatically, I seem to remember that FORTRAN does this. Maybe Pascal did this also? It has been a very long time since I've used these languages and my memory is hazy.

Anyway some languages do a "-1" for you. This slows things down a very slight bit, but does it matter? Probably not in the case of a single array.

This address 4+0 idea is very powerful when working with loop constructs and has the ability to simplify the code when working with "pointers" or "references".

In reply to Re: why the array index has to start at 0?? by Marshall
in thread why the array index has to start at 0?? by targetsmart

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (4)
    As of 2018-05-26 12:33 GMT
    Find Nodes?
      Voting Booth?