Leading zero
≈ 5 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
A leading zero is any 0 digit that comes before the first nonzero digit in a number string in positional notation. For example, James Bond's famous identifier, 007, has two leading zeros. Any zeros appearing to the left of the first non-zero digit before the decimal point do not affect its value, and can be omitted (or replaced with blanks) with no loss of information. Therefore, the usual decimal notation of integers does not use leading zeros except for the zero in the ones place, which would be denoted as an empty string otherwise. However, for digits after the decimal point, the leading zeros between the decimal point and the first nonzero digit are necessary for conveying the magnitude of a number and cannot be omitted (ex. 0.001), while trailing zeros – zeros occurring after the decimal point and after the last nonzero digit – can be omitted without changing the meaning (ex. 0.00100).
A leading zero is any 0 digit that comes before the first nonzero digit in a number string in positional notation. For example, James Bond's famous identifier, 007, has two leading zeros. Any zeros appearing to the left of the first non-zero digit before the decimal point do not affect its value, and can be omitted (or replaced with blanks) with no loss of information. Therefore, the usual decimal notation of integers does not use leading zeros except for the zero in the ones place, which would be denoted as an empty string otherwise. However, for digits after the decimal point, the leading zeros between the decimal point and the first nonzero digit are necessary for conveying the magnitude of a number and cannot be omitted (ex. 0.001), while trailing zeros – zeros occurring after the decimal point and after the last nonzero digit – can be omitted without changing the meaning (ex. 0.00100).
Collation
Leading zeros are used to make ascending order of numbers correspond with alphabetical order: e.g., 11 comes alphabetically before 2, but after 02. (See, e.g., ISO 8601.) This does not work with negative numbers, though, whether leading zeros are used or not: −23 comes alphabetically after −01, −1, and −22, although it is less than all of them.
Error prevention
Leading zeros in a sentence also make it less likely that a careless reader will overlook the decimal point. For example, in modern pharmacy there is a widely followed convention that leading zeros before a decimal must not be omitted from any dose or dosage value in drug prescribing (e.g. 0.2 mg must be used, not .2 mg). Meanwhile, trailing zeros are forbidden (e.g. 2 mg must be used, not 2.0 mg). In both cases, the intention is to prevent misreading and the resultant misdose by one or several orders of magnitude.
Fraud prevention
Leading zeros can also be used to prevent fraud by filling in character positions that might normally be empty. For example, adding leading zeros to the amount of a check (or similar financial document) makes it more difficult for fraudsters to alter the amount of the check before presenting it for payment. A prefix 0 is used in C to specify string representations of octal numbers, as required by the ANSI C standard for the strtol() function (which converts strings to long integers) in the library. Many other programming languages, such as Python, Perl, Ruby, PHP, and the Unix shell bash also follow this specification for converting strings to numbers. As an example, " 0020 " does not represent 20 10 (2×10 1 + 0×10 0 ), but rather 20 8 = 16 10 (2×8 1 + 0×8 0 = 1×10 1 + 6×10 0 ). Decimal numbers written with leading zeros will be interpreted as octal by languages that follow this convention and will generate errors if they contain "8" or "9", since these digits do not exist in octal. This behavior can be a nuisance when working with sequences of strings with embedded, zero-padded decimal numbers (typically file names) to facilitate alphabetical sorting (see above) or when validating inputs from users who would not know that adding a leading zero triggers this base conversion. In Czechia, a zero prefix was formerly used as one of ways how to indicate a type of house number. As the standard house numbers, conscription house numbers (čísla popisná) are used. However, for temporary and recreational structures, a special number series of registration house numbers (čísla evidenční) is used. This type is distinguished by any prefix (0, E or N), by a distinguishing text or abbreviation or by color of the sign.
See also
Trailing zero 00 (disambiguation) Leading digit
References
Text derived from https://en.wikipedia.org/w/index.php?oldid=1360767991 under CC BY-SA 4.0; modifications have been made.