# 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
Life and Style

tech
News

people
Life and Style

fashion
News

### Adolescents are the biggest liars. But why?

scienceRoger Dobson knows the true story, from Pinocchio to Pollard
Life and Style

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

ebookNow available in paperback
ebooks

### Mark Hix on Meat

ebookA delicious collection of 50 meaty main courses
News

i100
News

people
News

i100
Sport

transfers
News

news
Life and Style

health
Voices

### Aches, pains and an inkling of mortality

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

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

booksMan Booker Prize nominee Anna Smaill on the rise of Kiwi lit
Sport

### Ji So-Yun seals FA Cup trophy for Chelsea Ladies

sport
Arts and Entertainment

art
Life and Style

food + drink

### Donna Karan leaves Donna Karan, but DKNY soldiers on

##### Independent Dating
and

By clicking 'Search' you
are agreeing to our

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

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

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

VIPs gather for opening of second Suez Canal - but is it really needed?

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

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

## 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's seaside-inspired recipes

These dishes are so easy to make, our chef is almost embarrassed to call them recipes

## Andrew Grice: Inside Westminster

Blairites be warned, this could be the moment Labour turns into Syriza

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

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

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

## Secrets of comedy couples

What's it like when both you and your partner are stand-ups?

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