Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Zero-based numbering
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Origin === [[Martin Richards (computer scientist)|Martin Richards]], creator of the [[BCPL]] language (a precursor of [[C (programming language)|C]]), designed arrays initiating at 0 as the natural position to start accessing the array contents in the language, since the value of a [[pointer (computer programming)|pointer]] ''p'' used as an address accesses the position {{nowrap|''p'' + 0}} in memory.<ref>{{cite book |url=http://cm.bell-labs.com/cm/cs/who/dmr/bcpl.pdf |title=The BCPL Reference Manual |publisher=Massachusetts Institute of Technology |author=Martin Richards |year=1967 |page=11}}</ref><ref name="mikehoye">{{cite web |url=http://exple.tive.org/blarg/2013/10/22/ |title=Cita{{not a typo|tion Nee}}ded |access-date=28 January 2014 |author=Mike Hoye}}</ref> BCPL was first compiled for the [[IBM 7094]]; the language introduced no [[Run time (program lifecycle phase)|run-time]] [[indirection lookup]]s, so the indirection optimization provided by these arrays was done at compile time.<ref name="mikehoye"/> The optimization was nevertheless important.<ref name="mikehoye"/><ref>{{cite web |url=https://www.multicians.org/thvv/7094.html |title=The IBM 7094 and CTSS |date=1995 |access-date=28 January 2014 |author=Tom Van Vleck}}</ref> In 1982 [[Edsger W. Dijkstra]] in his pertinent note ''Why numbering should start at zero''<ref name="dijkstra"/> argued that arrays subscripts should start at zero as the latter being the most [[natural number]]. Discussing possible designs of array ranges by enclosing them in a chained inequality, combining sharp and standard inequalities to four possibilities, demonstrating that to his conviction zero-based arrays are best represented by non-overlapping index ranges, which start at zero, alluding to [[Interval (mathematics)#Definitions|open, half-open and closed intervals]] as with the real numbers. Dijkstra's criteria for preferring this convention are in detail that it represents empty sequences in a more natural way {{nowrap|(''a'' β€ ''i'' < ''a'' ?)}} than closed "intervals" ({{nowrap|''a'' β€ ''i'' β€ (''a'' β 1) ?}}), and that with half-open "intervals" of naturals, the length of a sub-sequence equals the upper minus the lower bound ({{nowrap|''a'' β€ ''i'' < ''b''}} gives {{nowrap|(''b'' β ''a'')}} possible values for ''i'', with ''a'', ''b'', ''i'' all integers).
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)