A-Z of the digital world
Monday 29 July 1996
Hackers and computer scientists, unwilling to let their obsessions remain computer-based, 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 Brian Kernighan and Dennis Ritchie's book The C Programming Language. In recent years this trait has also been observed among many pure mathematicians (who have an independent tradition of numbering from 0, and getting into fights after a few beers in bars over what sort of integer zero is).
Zero-based numbering does actually have real usefulness: it reduces the likelihood of "fencepost errors", which can easily occur in programs that repeat a calculation until some boundary condition is true - that is, perform an "iterative loop".
Fencepost errors are so named from the problem known to settlers in the Wild West: how many posts are needed to build a fence 10 metres long with 1 metre between each post? (Clue: the answer is not 10.) Or suppose you have a long list of items, and want to process items m through n: how many items are there to process? The obvious answer is n-m, but that is off by one; the right answer is (n-m+1). A program that used the "obvious" formula would have a fencepost error in it. However, if you rest the list of items to be processed into an array that started numbering at 0, you wouldn't. Which is why sometimes it's better to be zeroth than first.
Life & Style blogs
Well, it seemed like a good idea at the time: 10 worst gadgets of recent times
The secret to a great sex life revealed: Two cups of coffee a day
New Zealand 'the best country to work as a prostitute', says sex worker advocacy group
What do the emoji on Snapchat mean?
Facebook status updates indicates whether a user is narcissistic or neurotic, research finds
As a white man, I'm surprised more women aren't tweeting the hashtag #KillAllWhiteMen
Scotland may have to leave the EU even if it votes to stay in, David Cameron confirms
Report finds that Britain's wages are the most unequal in Europe
The day that Britain resigned as a global power
Almost a third of school pupils believe 'Muslims are taking over our country', study claims
SNP fury as HS2 finds 'no business case' for taking fast train service to Scotland
- 1 Games of Thrones actor Lena Headey makes emotional promise to her unborn daughter
- 2 Isis burns woman alive for refusing to engage in 'extreme' sex act, UN says
- 3 Puerto Rico, island of lost dreams: People are leaving the debt-hit territory in droves as near neighbour Cuba's star rises
- 4 Female Muay Thai champion hustles coaches to give them a beating
- 5 16-year-old girl beaten and burned alive by lynch mob in Rio Bravo, Guatemala
£40-50K: Guru Careers: We are seeking an experienced Software / C# Developer w...
£35 - 40k + Benefits: Guru Careers: We are seeking a Software Developer (JavaS...
£18000 - £23000 per annum + Commission: SThree: As a Trainee Recruitment Consu...