A-Z of the digital world

Z is for Zeroth. With a neat circularity that should please the true hacker - the last item in our catalogue means "first". For software designers working in C and the artificial intelligence language Lisp, the first item in a list is always the "zeroth" (zee-rowth). Hardware people also tend to start counting at 0 instead of 1 - a natural result of the fact that the 256 states of 8 bits correspond to the binary numbers 0, 1, ..., 255 and the digital devices known as "counters" count in this way.

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.

PROMOTED VIDEO
Have you tried new the Independent Digital Edition apps?
Life and Style
ebookNow available in paperback
ebooks
ebookPart of The Independent’s new eBook series The Great Composers
News
Buddy DeFranco
people
Arts and Entertainment
British actor Idris Elba is also a DJ and rapper who played Ibiza last summer
filmIdris Elba responds to James Bond rumours on Twitter
Arts and Entertainment
Lena Headey as Cersei Lannister in Game of Thrones
film
News
i100
Sport
Yaya Sanogo, Mats Hummels, Troy Deeney and Adnan Januzaj
footballMost Premier League sides are after a striker, but here's a full run down of the ins and outs that could happen over the next month
Latest stories from i100
Have you tried new the Independent Digital Edition apps?
Independent Dating
and  

By clicking 'Search' you
are agreeing to our
Terms of Use.

ES Rentals

    iJobs Job Widget
    iJobs General

    Recruitment Genius: Business Manager

    £32000 - £40000 per annum: Recruitment Genius: A Business Manager is required ...

    Recruitment Genius: Operations Manager

    £45000 - £55000 per annum: Recruitment Genius: This is an exciting opportunity...

    Recruitment Genius: Panel & Cabinet Wireman

    £20000 per annum: Recruitment Genius: Panel Wireman required for small electro...

    Recruitment Genius: Electronics Test Engineer

    £25000 - £27000 per annum: Recruitment Genius: An SME based in East Cheshire, ...

    Day In a Page

    Ed Richards: Parting view of Ofcom chief. . . we hate jokes on the disabled

    Ed Richards: Parting view of Ofcom chief. . . we hate jokes on the disabled

    Bad language once got TV viewers irate, inciting calls to broadcasting switchboards. But now there is a worse offender, says retiring head of the media watchdog
    War with Isis: The West needs more than a White Knight

    The West needs more than a White Knight

    Despite billions spent on weapons, the US has not been able to counter Isis's gruesome tactics, says Patrick Cockburn
    Return to Helmand: Private Davey Graham recalls the day he was shot by the Taliban

    'The day I was shot by the Taliban'

    Private Davey Graham was shot five times during an ambush in 2007 - it was the first, controversial photograph to show the dangers our soldiers faced in Helmand province
    Revealed: the best and worst airlines for delays

    Revealed: the best and worst airlines for delays

    Many flyers are failing to claim compensation to which they are entitled, a new survey has found
    The stories that defined 2014: From the Scottish independence referendum to the Ice Bucket Challenge, our writers voice their opinions

    The stories that defined 2014

    From the Scottish independence referendum to the Ice Bucket Challenge, our writers voice their opinions
    Stoke-on-Trent becomes first British city to be classified as 'disaster resilient' by the United Nations

    Disaster looming? Now you know where to head...

    Which British city has become the first to be awarded special 'resilience' status by the UN?
    Finally, a diet that works: Californian pastor's wildly popular Daniel Plan has seen his congregation greatly reduced

    Finally, a diet that works

    Californian pastor's wildly popular Daniel Plan has seen his congregation greatly reduced
    Say it with... lyrics: The power of song was never greater, according to our internet searches

    Say it with... lyrics

    The power of song was never greater, according to our internet searches
    Professor Danielle George: On a mission to bring back the art of 'thinkering'

    The joys of 'thinkering'

    Professor Danielle George on why we have to nurture tomorrow's scientists today
    Monique Roffey: The author on father figures, the nation's narcissism and New Year reflections

    Monique Roffey interview

    The author on father figures, the nation's narcissism and New Year reflections
    Introducing my anti-heroes of 2014

    Introducing my anti-heroes of 2014

    Their outrageousness and originality makes the world a bit more interesting, says Ellen E Jones
    DJ Taylor: Good taste? It's all a matter of timing...

    Good taste? It's all a matter of timing...

    It has been hard to form generally accepted cultural standards since the middle of the 19th century – and the disintegration is only going to accelerate, says DJ Taylor
    Olivia Jacobs & Ben Caplan: 'Ben thought the play was called 'Christian Love'. It was 'Christie in Love' - about a necrophiliac serial killer'

    How we met

    Olivia Jacobs and Ben Caplan
    Bill Granger recipes: Our chef's breakfasts will revitalise you in time for the New Year

    Bill Granger's healthy breakfasts

    Our chef's healthy recipes are perfect if you've overindulged during the festive season
    Transfer guide: From Arsenal to West Ham - what does your club need in the January transfer window?

    Who does your club need in the transfer window?

    Most Premier League sides are after a striker, but here's a full run down of the ins and outs that could happen over the next month