# GetWiki

*Zero-based numbering*

ARTICLE SUBJECTS

being →

database →

ethics →

fiction →

history →

internet →

language →

linux →

logic →

method →

news →

policy →

purpose →

religion →

science →

software →

truth →

unix →

wiki →

ARTICLE TYPES

essay →

feed →

help →

system →

wiki →

ARTICLE ORIGINS

critical →

forked →

imported →

original →

Zero-based numbering

[ temporary import ]

**please note:**

- the content below is remote from Wikipedia

- it has been imported raw for GetWiki

**Zero-based numbering**or

*index origin = 0*JOURNAL, Brown, Jim, In Defense of Index Origin 0, ACM SIGAPL APL Quote Quad, December 1978, 9, 2, 7, 10.1145/586050.586053, WEB, Hui, Roger, Is Index Origin 0 a Hindrance?,weblink jsoftware.com, JSoftware, 19 January 2015, is a way of numbering in which the initial element of a sequence is assigned the index 0, rather than the index 1 as is typical in everyday

*non-mathematical*or

*non-programming*circumstances. Under zero-based numbering, the initial element is sometimes termed the

*zeroth*element{{citation needed|date=March 2019}}, rather than the

*first*element;

*zeroth*is a coined ordinal number corresponding to the number zero. In some cases, an object or value that does not (originally) belong to a given sequence, but which could be naturally placed before its initial element, may be termed the zeroth element. There is not wide agreement regarding the correctness of using zero as an ordinal (nor regarding the use of the term

*zeroth*) as it creates ambiguity for all subsequent elements of the sequence when lacking context.Numbering sequences starting at 0 is quite common in mathematics notation, in particular in combinatorics, though programming languages for mathematics usually index from 1. In computer science, array indices usually start at 0 in modern programming languages, so computer programmers might use

*zeroth*in situations where others might use

*first*, and so forth. In some mathematical contexts, zero-based numbering can be used without confusion, when ordinal forms have well established meaning with an obvious candidate to come before

*first*; for instance a

*zeroth derivative*of a function is the function itself, obtained by differentiating zero times. Such usage corresponds to naming an element not properly belonging to the sequence but preceding it: the zeroth derivative is not really a derivative at all. However, just as the

*first derivative*precedes the

*second derivative*, so also does the

*zeroth derivative*(or the original function itself) precede the

*first derivative*.

## Computer programming

### Origin

Martin Richards, creator of the BCPL language (a precursor of 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*p*used as an address accesses the position

*p*+ 0 in memory.BOOK,weblink The BCPL Reference Manual, Massachusetts Institute of Technology, Martin Richards, 1967, 11, WEB,weblink Citation Needed, 28 January 2014, Mike Hoye, Canadian systems analyst Mike Hoye asked Richards the reasons for choosing that convention. BCPL was first compiled for the IBM 7094; the language introduced no indirection lookups at run time, so the indirection optimization provided by these arrays was used at compile time. The optimization was nevertheless important, as batch processes in the system could be interrupted at any time to calculate yacht handicapping for the president of IBM's racing yacht.WEB,weblink The IBM 7094 and CTSS, 1995, 28 January 2014, Tom Van Vleck, Edsger W. Dijkstra later wrote a pertinent note

*Why numbering should start at zero*in 1982, analyzing the possible designs of array indices 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 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 (

*a*â‰¤

*i*<

*a*?) than closed "intervals" (

*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 (

*a*â‰¤

*i*<

*b*gives (

*b*âˆ’

*a*) possible values for

*i*, with

*a*,

*b*,

*i*all naturals).

### {{Anchor|OFFSET}}Usage in programming languages

This usage follows from design choices embedded in many influential programming languages, including C, Java, and Lisp. In these three, sequence types (C arrays, Java arrays and lists, and Lisp lists and vectors) are indexed beginning with the zero subscript. Particularly in C, where arrays are closely tied to pointer arithmetic, this makes for a simpler implementation: the subscript refers to an offset from the starting position of an array, so the first element has an offset of zero.Referencing memory by an address and an offset is represented directly in computer hardware on virtually all computer architectures, so this design detail in C makes compilation easier, at the cost of some human factors. In this context using "zeroth" as an ordinal is not strictly correct, but a widespread habit in this profession. Other programming languages, such as Fortran or COBOL, have array subscripts starting with one, because they were meant as high-level programming languages, and as such they had to have a correspondence to the usual ordinal numbers which predate the invention of the zero by a long time.Pascal allows the range of an array to be of any ordinal type (including enumerated types. APL allows changing between 0 or 1 origin during runtime programatically as the programmers finds convenient. Some recent languages, such as Lua and Visual Basic, have adopted the same convention for the same reason.Zero is the lowest unsigned integer value, one of the most fundamental types in programming and hardware design. In computer science, zero is thus often used as the base case for many kinds of numerical recursion. Proofs and other sorts of mathematical reasoning in computer science often begin with zero. For these reasons, in computer science it is not unusual to number from zero rather than one.Hackers and computer scientists often like to call the first chapter of a publication "Chapter 0", especially if it is of an introductory nature. One of the classic instances was in the First Edition of K&R. In recent years this trait has also been observed among many pure mathematicians, where many constructions are defined to be numbered from 0.If an array is used to represent a cycle, it is convenient to obtain the index with a modulo function, which can result in zero.### Numerical properties

With zero-based numbering, a range can be expressed as the half-open interval, [0,*n*), as opposed to the closed interval, [1,

*n*]. Empty ranges, which often occur in algorithms, are tricky to express with a closed interval without resorting to obtuse conventions like [1,0]. Because of this property, zero-based indexing potentially reduces off-by-one and fencepost errors.WEB,weblink Why numbering should start at zero (EWD 831), Dijkstra, Edsger Wybe, Edsger W. Dijkstra, May 2, 2008, E. W. Dijkstra Archive, University of Texas at Austin, 2011-03-16, On the other hand, the repeat count

*n*is calculated in advance, making the use of counting from 0 to

*n*âˆ’1 (inclusive) less intuitive. Some authors prefer one-based indexing as it corresponds more closely to how entities are indexed in other contexts.Programming MicrosoftÂ® Visual C#Â® 2005 by Donis MarshallAnother property of this convention is in the use of modular arithmetic as implemented in modern computers. Usually, the modulo function maps any integer modulo

*N*to one of the numbers 0, 1, 2, ..., {{nowrap|

*N*âˆ’ 1}}, where {{nowrap|

*N*â‰¥ 1}}. Because of this, many formulas in algorithms (such as that for calculating hash table indices) can be elegantly expressed in code using the modulo operation when array indices start at zero.Pointer operations can also be expressed more elegantly on a zero-based index due to the underlying address/offset logic mentioned above. To illustrate, suppose

*a*is the memory address of the first element of an array, and

*i*is the index of the desired element. To compute the address of the desired element, if the index numbers count from 1, the desired address is computed by this expression:

*a*+

*s*Ã— (

*i*âˆ’ 1)

*s*is the size of each element. In contrast, if the index numbers count from 0, the expression becomes:

*a*+

*s*Ã—

*i*

*a*â€² =

*a*â€“

*s*; that is, rather than using the address of the first array element, such a language would use the address of a fictitious element located immediately before the first actual element. The indexing expression for a 1-based index would then be:

*a*â€² +

*s*Ã—

*i*

*r*in the linear array to access a specific element with {{nowrap|L[

*r*] {{=}} A[

*z*][

*y*][

*x*]}} in zero-based indexing, i.e. [0 â‰¤

*x*< P], [0 â‰¤

*y*< N], [0 â‰¤

*z*< M], and [0 â‰¤

*r*< Mâ‹…Nâ‹…P], is calculated by {{nowrap|

*r*{{=}}

*z*â‹…Mâ‹…N +

*y*â‹…M +

*x*}}. Organizing all arrays with 1-based indices ([1 â‰¤

*xâ€²*â‰¤ P], [1 â‰¤

*yâ€²*â‰¤ N], [1 â‰¤

*zâ€²*â‰¤ M], [1 â‰¤ râ€² â‰¤ Mâ‹…Nâ‹…P]), and assuming an analogous arrangement of the elements, gives {{nowrap|

*râ€²*{{=}} (

*zâ€²*− 1)â‹…Mâ‹…N + (

*yâ€²*− 1)â‹…M + (

*xâ€²*− 0)}} to access the same element, which arguably looks more complicated. Of course, {{nowrap|

*r*' {{=}}

*r*+ 1,}} since [{{nowrap|

*z*{{=}}

*zâ€²*â€“ 1],}} [{{nowrap|

*y*{{=}}

*yâ€²*â€“ 1],}} and [{{nowrap|

*x*{{=}}

*xâ€²*â€“ 1].}} When applied to positional notation with base 10 this demonstrates that the numbers of tens, hundreds, thousands etc. are always counted from zero, whereas units are counted from one (if there are any at all) in everyday lifeAV MEDIA,weblink Math 1st Grade / Place Value / Number grid, Youtube title: Number grid / Counting / Early Math / Khan Academy, Khan Academy, Sal Khan, July 28, 2018, :{| class="wikitable" style="text-align: right;"|+

*Zero*-based indices!x y !! 0 !! 1 !! 2 !! .. !! x = xâ€² - 1 !! .. !! 8 !! 9

00 > | 01 > | 02 > | 08 >| 09 |

| 19 |

| 29 |

| |

| |

| |

| 89 |

| 99 |

The table content represents the index r |

*One*-based indices! xâ€² yâ€² !! 1 !! 2 !! 3 !! .. !! xâ€² = x + 1 !! .. !! 9 !! 10

01 > | 02 > | 03 > | 09 >| 10 |

| 20 |

| 30 |

| |

| |

| |

| 90 |

| 100 |

The table content represents the index râ€² |

*n*objects will be {{nowrap|

*n*âˆ’ 1}} and it refers to the

*n*th element. For this reason, the first element is sometimes referred to as the zeroth element, in an attempt to avoid confusion.

## Science

In mathematics, many sequences of numbers or of polynomials are indexed by nonnegative integers, for example the Bernoulli numbers and the Bell numbers.The*zeroth law of thermodynamics*was formulated after the first, second, and third laws, but considered more fundamental, thus its name.In biology, an organism is said to have zero order intentionality if it shows "no intention of anything at all". This would include a situation where the organism's genetically predetermined phenotype results in a fitness benefit to itself, because it did not "intend" to express its genes.WEB,weblink The Thinking Ape: Evolutionary Origins of Intelligence., 2010-05-18, Byrne, Richard W., In the similar sense, a computer may be considered from this perspective a zero order intentional entity as it does not "intend" to express the code of the programs it runs.WEB,weblink The Human Story - A new history of mankind's Evolution, 2010-05-18, Dunbar, Robin, In biological or medical experiments, initial measurements made before any experimental time has passed are said to be on the 0 day of the experiment.In genomics, both 0-based and 1-based systems are used for genome coordinates.Patient zero (or index case) is the initial patient in the population sample of an epidemiological investigation.

## Other fields

The year zero does not exist in the widely used Gregorian calendar or in its predecessor, the Julian calendar. Under those systems, the year 1 BC is followed by AD 1. However, there is a year zero in astronomical year numbering (where it coincides with the Julian year 1 BC) and in (ISO 8601|ISO 8601:2004) (where it coincides with the Gregorian year 1 BC) as well as in all Buddhist and Hindu calendars.In many countries, the ground floor in buildings is considered as floor number 0 rather than as the "1st Floor", the naming convention usually found in the United States of America. This makes a consistent set with underground floors marked with negative numbers.While the ordinal of 0 mostly finds use in communities directly connected to mathematics, physics, and computer science, there are also instances in classical music. The composer Anton Bruckner regarded his early*Symphony in D minor*to be unworthy of including in the canon of his works, and he wrote 'gilt nicht' on the score and a circle with a crossbar, intending it to mean "invalid". But posthumously, this work came to be known as

*Symphony No. 0 in D minor*, even though it was actually written after

*Symphony No. 1 in C minor*. There is an even earlier

*Symphony in F minor*of Bruckner's that is sometimes called

*No. 00*. The Russian composer Alfred Schnittke also wrote a Symphony No. 0.In some universities, including Oxford and Cambridge, "week 0" or occasionally "noughth week" refers to the week before the first week of lectures in a term. In Australia, some universities refer to this as "O Week", which serves as a pun on "orientation week". As a parallel, the introductory weeks at university educations in Sweden are generally called "nollning" (zeroing).The United States Air Force starts basic training each Wednesday, and the first week (of eight) is considered to begin with the following Sunday. The four days before that Sunday are often referred to as "Zero Week."24-hour clocks and the international standard ISO 8601 use 0 to denote the first (zeroth) hour of the day.King's Cross station in London, Edinburgh Haymarket, and stations in Uppsala, Yonago, Stockport and Cardiff have a platform 0.Robert Crumb's drawings for the first issue of

*Zap Comix*were stolen, so he drew a whole new issue which was published as issue 1. Later he re-inked his photocopies of the stolen artwork and published it as issue 0.The Brussels ring road in Belgium is numbered R0. It was built after the ring road around Antwerp, but Brussels (being the capital city) was deemed deserving of a more basic number. Similarly the (unfinished) orbital motorway around Budapest in Hungary is called M0.Zero is sometimes used in street addresses, especially in schemes where even numbers are one side of the street and odd numbers on the other. A case in point is the landmark Christ Church Cambridge on Cambridge, Massachusetts's Harvard Square, whose address is 0 Garden Street.In Formula One, when a defending world champion does not compete in the following season, the number 1 is not assigned to any driver, but one driver of the world champion team will carry the number 0, and the other, number 2. This did happen both in 1993 and 1994 with Damon Hill carrying the number 0 in both seasons, as defending champion Nigel Mansell quit after 1992, and defending champion Alain Prost quit after 1993.A chronological prequel of a series may be numbered as 0, such as

*(Ring 0: Birthday)*or

*Zork Zero*.The Swiss Federal Railways number certain classes of rolling stock from zero, for example, Re 460 000 to 118.In the realm of fiction, Isaac Asimov eventually added a Zeroth Law to his Three Laws of Robotics, essentially making them four laws.

## See also

## References

{{reflist|30em}}- General

**- content above as imported from Wikipedia**

- "

- time: 3:52pm EDT - Mon, Mar 18 2019

- "

__Zero-based numbering__" does not exist on GetWiki (yet)- time: 3:52pm EDT - Mon, Mar 18 2019

[ this remote article is provided by Wikipedia ]

LATEST EDITS [ see all ]

GETWIKI 09 MAY 2016

GETWIKI 18 OCT 2015

GETWIKI 20 AUG 2014

GETWIKI 19 AUG 2014

GETWIKI 18 AUG 2014

© 2019 M.R.M. PARROTT | ALL RIGHTS RESERVED