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
Looking past the search results: Google 2.0 will 'build airports and cities' says report
Jennifer Lawrence nude pictures leaked: Reddit removes 'The Fappening' board dedicated to sharing naked pictures of celebrities
Anti-depressants can change how the brain works in just hours
iPhone 'Wave': iOS 8 hoax claims you can charge your iPhone in the microwave - you can't
The 'Angelina Jolie effect': Her mastectomy revelation doubled NHS breast cancer testing referrals
Daniele Watts: Django Unchained actress detained by Los Angeles police after being mistaken for a prostitute
Scottish independence referendum: A nation divided against itself
Scottish referendum results: Cross-party consensus collapses amid Tory-Labour spat on the 'English question'
Scottish independence: David Cameron is becoming the 'George Bush of Britain'
Russia freezes Ukraine into submission: Kiev admits country doesn't have enough fuel for winter
Scottish independence: The Queen breaks silence on referendum debate – as think tank warns of £14bn black hole if Scotland votes Yes
- 1 Mario Balotelli: Staff at arson-hit Manchester Dogs' Home convinced Liverpool striker is behind five-figure donation
- 2 Friends 20th anniversary: Alison Jackson photographs reunited cast
- 3 A bottle of wine a day is not bad for you and abstaining is worse than drinking, scientist claims
- 4 The response to my Pizza Express review has been overwhelming, and taught me a lot about journalism
- 5 Free U2 album: How the most generous giveaway in music history turned into a PR disaster
£75 - £90 per day + negotiable: Randstad Education Group: Are you a cover supe...
£30000 - £35000 per annum: Ashdown Group: Marketing Manager (CIM, B2B, MS Offi...
£22000 - £25000 per annum: Ashdown Group: A highly successful organisation wit...
£1 per day: Randstad Education Leeds: Job Purpose To work closely with the he...