# 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.

Suggested Topics
Arts and Entertainment

### Abuse - and the hell that came afterwards

booksPianist James Rhodes on the extraordinary legal battle to stop the injunction of his memoirs
Arts and Entertainment

### Palme d'Or goes to radical film that upends conventional thinking about immigrants

filmDheepan, film review
Sport

### Stoke players 'let Gerrard score in his final game'

sport
Arts and Entertainment

art
Life and Style

### A History of The Great War in 100 Moments

ebookNow available in paperback
Sport

sport
News

people
News

news
Sport

sport
News

people
News

### George Osborne backed out of 'promise to French kiss' Wizard of Oz

peopleChancellor accused of reneging on pre-election promise
Arts and Entertainment

music
News

people
Sport

sport
News

### Poor should stop blaming inequality on the rich – says Warren Buffett (the world's third richest man)

people
Arts and Entertainment

### Top Gear trio returns with fireworks, AC/DC and 'automotive pornography'

reviewSimon Usborne on Clarkson, Hammond and May Live
Life and Style

love + sex
Life and Style

love + sex
News

news
Voices

voices

### Dior and I: an artful argument for a new couture

##### Independent Dating
and

By clicking 'Search' you
are agreeing to our

### Guru Careers: Software Developer / C# Developer

£40-50K: Guru Careers: We are seeking an experienced Software / C# Developer w...

### Guru Careers: Software Developer

£35 - 40k + Benefits: Guru Careers: We are seeking a Software Developer (JavaS...

### SThree: Trainee Recruitment Consultant / Resourcer

£18000 - £23000 per annum + Commission: SThree: As a Trainee Recruitment Consu...

### Ashdown Group: UI Developer - (UI, HTML, CSS, JavaScript, AngularJS)

£25000 - £40000 per annum: Ashdown Group: UI Developer - (UI, JavaScript, HTML...

## Sun, sex and an anthropological study

One academic’s summer of hell in Magaluf

## Frances de la Tour's 50-year triumph

'Rising Damp' brought De la Tour such recognition that she could be forgiven if she'd never been able to move on. But at 70, she continues to flourish - and to beguile

## Ian McMillan on the Whitsun Weddings

This weekend is Whitsun, and while the festival may no longer resonate, Larkin's best-loved poem, lives on - along with the train journey at the heart of it

## Songs from the bell jar

Kathryn Williams explores the works and influences of Sylvia Plath

## One man's day in high heels

...showed him that Cannes must change its 'flats' policy

## Is a quiet crusade to reform executive pay bearing fruit?

Dominic Rossi of Fidelity says his pressure on business to control rewards is working. But why aren’t other fund managers helping?

## King David Hotel: Palestinians not included

The King David is special to Jerusalem. Nick Kochan checked in and discovered it has some special arrangements, too

## End of the Aussie brain drain

More people moving from Australia to New Zealand than in the other direction for first time in 24 years

## Can meditation be bad for you?

Researching a mass murder, Dr Miguel Farias discovered that, far from bringing inner peace, meditation can leave devotees in pieces

## Australia's first-ever Eurovision entrant

Australia, a nation of kitsch-worshippers, has always loved the Eurovision Song Contest. Maggie Alderson says it'll fit in fine

## Laughter, but no tears, as Letterman takes his bow after 33 years

Veteran talkshow host steps down to plaudits from four presidents

## Hozier's 'blasphemous' song takes Novello award

Singer joins Ed Sheeran and Clean Bandit in celebration of the best in British and Irish music

## Join the tequila gold rush

The spirit has gone from a cheap shot to a multi-billion pound product

## 12 best statement wallpapers

Make an impact and transform a room with a conversation-starting pattern

## Paul Scholes column

Does David De Gea really want to leave Manchester United to fight it out for the No 1 spot at Real Madrid?