Reply to Re: A List of One.

Your name:

Reply:


Posted by Jukka K. Korpela on 04/10/06 09:04

dorayme <doraymeRidThis@optusnet.com.au> wrote:

>> In computer-related languages, the first thing is usually the "0" thing.
>> Javascript, for example, numbers the initial item in the images array
>> (-and all arrays) "0". It can be argued that a zero item
>
> Using 0-9 is just a way of counting (saves having to use "10"), I
> would not draw too many deep conclusions from it Boji.

The reason for starting indexing from 0 in most programming languages is that
at the level of machine-language implementation, indexing is a matter of
adding the index value, possibly multiplied by a constant, to a base address.
We can consider this at a more logical level, too: we could _define_ an
indexed variable as a shorthand for adding a displacement. In C terms,
a[i] is equivalent to *(a+i), thanks to indexes starting from zero.

This is also reflected in HTML. In client-side image maps, the coordinate
values used in <area> elements are indexes in a sense, and they start from
zero, i.e. the upper left corner of the image is (0,0).

Astonishingly, the HTML 4.01 specification "Errata" says:

"15. It is not specified whether the values of the "coords" attribute (A and
AREA elements) are 0-based or 1-based
Added: 12 May 2001
Type: Error
Refers to: 24 Dec 1999 version, section 13.6.1 AREA element declaration.
Description: The specification is unclear about whether x,y coordinates are
0-based or 1-based. Is the top left corner (0,0) or (1,1)?
Correction: None yet (seeking HTML WG input)."

http://www.w3.org/MarkUp/html4-updates/errata

After about five years, they still haven't decided on this. This confusion is
quite unnecessary, since starting from (0,0) is the only sensible way, and
the examples in the specification make it clear that (0,0) shall it be.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация