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
Childcare 'not just a women's issue,' says shadow minister as she sets out her 'dadifesto'
Who is Teresa Fidalgo? Debunking the fake ghost story that's got Instagram spooked
Scottish salmon sales leap as Asia develops a taste
Grim second life of the 'breastaurant': The oft-loathed sector is booming in the States thanks to Hooters, Twin Peaks and Tilted Kilt
Health: When masturbation can be fatal: The practice of auto-erotic asphyxia is often concealed by a coroner's verdict. Monique Roffey looks at a lethal taboo
British actor Idris Elba cannot star as James Bond because he is black, says shock jock Rush Limbaugh
Millions of Britons struggling to feed themselves and facing malnourishment
Ukip member gets into Christmas spirit with Union Flag plea to Santa 'for our country back'
Germany anti-Islam protests: 17,000 march on Dresden against 'Islamification of the West'
Nigel Farage: Ukip leader named 'Briton of the year' by The Times
Immigrants make UK racist, says Ukip councillor Trevor Shonk
- 1 President of Argentina adopts Jewish godson to 'stop him turning into a werewolf'
- 2 ALS ice bucket challenge co-founder Corey Griffin drowns, aged 27
- 3 Stoke-on-Trent becomes first British city to be classified as 'disaster resilient' by the United Nations
- 4 Sir Winston Churchill’s family begged him not to convert to Islam, letter reveals
- 5 AirAsia flight QZ8501 missing: Search for plane carrying 162 passengers from Indonesia to Singapore suspended overnight
£32000 - £40000 per annum: Recruitment Genius: A Business Manager is required ...
£45000 - £55000 per annum: Recruitment Genius: This is an exciting opportunity...
£20000 per annum: Recruitment Genius: Panel Wireman required for small electro...
£25000 - £27000 per annum: Recruitment Genius: An SME based in East Cheshire, ...