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.

Have you tried new the Independent Digital Edition apps?
Life and Style
ebookNow available in paperback
ebooks
ebookA delicious collection of 50 meaty main courses
Voices
The male menopause: those affected can suffer hot flushes, night sweats, joint pain, low libido, depression and an increase in body fat, among other symptoms
voicesSo the male menopause is real, they say, but what would the Victorians, 'old' at 30, think of that, asks DJ Taylor
Arts and Entertainment
Anna Smaill’s debut novel, The Chimes, is a fusion of fantasy and romance
booksMan Booker Prize nominee Anna Smaill on the rise of Kiwi lit
Sport
Ji So-Yun scores the only goal of the game
sport
Arts and Entertainment
One of the Pyongyang posters, the slogan of which reads: ‘Let the exploits of the northern railway conductors shine!’
art
Life and Style
Linguine with mussels and fresh tomatoes
food + drink
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.

SPONSORED FEATURES

ES Rentals

    iJobs Job Widget
    iJobs General

    Recruitment Genius: Project Assistant

    £17000 per annum: Recruitment Genius: They are a leading company in the field ...

    Recruitment Genius: DBA Developer - SQL Server

    £30000 - £35000 per annum: Recruitment Genius: This is an exciting opportunity...

    Recruitment Genius: Office Manager

    £26041 - £34876 per annum: Recruitment Genius: There has never been a more exc...

    Recruitment Genius: Travel Customer Service and Experience Manager

    £14000 - £17000 per annum: Recruitment Genius: The fastest growing travel comp...

    Day In a Page

    Turkey-Kurdish conflict: Obama's deal with Ankara is a betrayal of Syrian Kurds and may not even weaken Isis

    US betrayal of old ally brings limited reward

    Since the accord, the Turks have only waged war on Kurds while no US bomber has used Incirlik airbase, says Patrick Cockburn
    VIPs gather for opening of second Suez Canal - but doubts linger over security

    'A gift from Egypt to the rest of the world'

    VIPs gather for opening of second Suez Canal - but is it really needed?
    Man Booker Prize 2015: Anna Smaill - How can I possibly be on the list with these writers I have idolised?

    'How can I possibly be on the list with these writers I have idolised?'

    Man Booker Prize nominee Anna Smaill on the rise of Kiwi lit
    Art of the state: Pyongyang propaganda posters to be exhibited in China

    Art of the state

    Pyongyang propaganda posters to be exhibited in China
    Jeremy Corbyn dresses abysmally. That's a great thing because it's genuine

    Jeremy Corbyn dresses abysmally. That's a great thing because it's genuine

    Fashion editor, Alexander Fury, applauds a man who clearly has more important things on his mind
    The male menopause and intimations of mortality

    Aches, pains and an inkling of mortality

    So the male menopause is real, they say, but what would the Victorians, 'old' at 30, think of that, asks DJ Taylor
    Bill Granger recipes: Heading off on holiday? Try out our chef's seaside-inspired dishes...

    Bill Granger's seaside-inspired recipes

    These dishes are so easy to make, our chef is almost embarrassed to call them recipes
    Blairites be warned, this could be the moment Labour turns into Syriza

    Andrew Grice: Inside Westminster

    Blairites be warned, this could be the moment Labour turns into Syriza
    HMS Victory: The mystery of Britain's worst naval disaster is finally solved - 271 years later

    The mystery of Britain's worst naval disaster is finally solved - 271 years later

    Exclusive: David Keys reveals the research that finally explains why HMS Victory went down with the loss of 1,100 lives
    Survivors of the Nagasaki atomic bomb attack: Japan must not abandon its post-war pacifism

    'I saw people so injured you couldn't tell if they were dead or alive'

    Nagasaki survivors on why Japan must not abandon its post-war pacifism
    Jon Stewart: The voice of Democrats who felt Obama had failed to deliver on his 'Yes We Can' slogan, and the voter he tried hardest to keep onside

    The voter Obama tried hardest to keep onside

    Outgoing The Daily Show host, Jon Stewart, became the voice of Democrats who felt the President had failed to deliver on his ‘Yes We Can’ slogan. Tim Walker charts the ups and downs of their 10-year relationship on screen
    RuPaul interview: The drag star on being inspired by Bowie, never fitting in, and saying the first thing that comes into your head

    RuPaul interview

    The drag star on being inspired by Bowie, never fitting in, and saying the first thing that comes into your head
    Secrets of comedy couples: What's it like when both you and your partner are stand-ups?

    Secrets of comedy couples

    What's it like when both you and your partner are stand-ups?
    Satya Nadella: As Windows 10 is launched can he return Microsoft to its former glory?

    Satya Nadella: The man to clean up for Windows?

    While Microsoft's founders spend their billions, the once-invincible tech company's new boss is trying to save it
    The best swimwear for men: From trunks to shorts, make a splash this summer

    The best swimwear for men

    From trunks to shorts, make a splash this summer