A leading zero is any
0 digit that comes before the first nonzero digit in a number string in
positional notation
Positional notation, also known as place-value notation, positional numeral system, or simply place value, usually denotes the extension to any radix, base of the Hindu–Arabic numeral system (or decimal, decimal system). More generally, a posit ...
.
[.] For example,
James Bond
The ''James Bond'' franchise focuses on James Bond (literary character), the titular character, a fictional Secret Intelligence Service, British Secret Service agent created in 1953 by writer Ian Fleming, who featured him in twelve novels ...
'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
The decimal numeral system (also called the base-ten positional numeral system and denary or decanary) is the standard system for denoting integer and non-integer numbers. It is the extension to non-integer numbers (''decimal fractions'') of th ...
notation of
integer
An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
s does not use leading zeros except for the
zero
0 (zero) is a number representing an empty quantity. Adding (or subtracting) 0 to any number leaves that number unchanged; in mathematical terminology, 0 is the additive identity of the integers, rational numbers, real numbers, and compl ...
in the ones place, which would be denoted as an
empty string
In formal language theory, the empty string, or empty word, is the unique String (computer science), string of length zero.
Formal theory
Formally, a string is a finite, ordered sequence of character (symbol), characters such as letters, digits ...
otherwise. However, for digits ''after'' the decimal point, the leading zeros between the
decimal point
FIle:Decimal separators.svg, alt=Four types of separating decimals: a) 1,234.56. b) 1.234,56. c) 1'234,56. d) ١٬٢٣٤٫٥٦., Both a comma and a full stop (or period) are generally accepted decimal separators for international use. The apost ...
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).
Occurrence
Often, leading zeros are found on non-electronic
digital displays or on such electronic ones as
seven-segment display
A seven-segment display is a display device for Arabic numerals, less complex than a device that can show more characters such as dot matrix displays. Seven-segment displays are widely used in digital clocks, electronic meters, basic calculators, ...
s, that contain fixed sets of digits. These devices include manual counters,
stopwatch
A stopwatch is a timepiece designed to measure the amount of time that elapses between its activation and deactivation.
A large digital version of a stopwatch designed for viewing at a distance, as in a sports stadium, is called a stop clock ...
es,
[.] odometer
An odometer or odograph is an instrument used for measuring the distance traveled by a vehicle, such as a bicycle or car. The device may be electronic, mechanical, or a combination of the two (electromechanical). The noun derives from ancient Gr ...
s, and
digital clocks.
Leading zeros are also generated by many older computer programs when creating values to assign to new records, accounts and other files, and as such are likely to be used by utility billing systems, human resources information systems and government databases. Many
digital camera
A digital camera, also called a digicam, is a camera that captures photographs in Digital data storage, digital memory. Most cameras produced today are digital, largely replacing those that capture images on photographic film or film stock. Dig ...
s and other electronic media recording devices use leading zeros when creating and saving new files to make names of the equal length.
Leading zeros are also present whenever the number of digits is fixed by the technical system (such as in a
memory register), but the stored value is not large enough to result in a non-zero
most significant digit. The
count leading zeros operation efficiently determines the number of leading zero
bits in a
machine word.
Leading zeros can have its meaning for various reasons:
* in data where, for any reason, a standard data length is required or expected, e.g. in identifiers like James Bond as 007.
* in cases where the digit does not represent a value but a distinguishing character, for example in telephone numbers
* in numerical codes where the meaning of digits is dependent on their position
A leading zero appears in
roulette
Roulette (named after the French language, French word meaning "little wheel") is a casino game which was likely developed from the Italy, Italian game Biribi. In the game, a player may choose to place a bet on a single number, various grouping ...
in the United States, where "00" is distinct from "0" (a wager on "0" will not win if the ball lands in "00", and vice versa). Sports where competitors are numbered follow this as well; a
stock car numbered "07" would be considered distinct from one numbered "7".
Benito Santiago, a
Major League Baseball
Major League Baseball (MLB) is a professional baseball league composed of 30 teams, divided equally between the National League (baseball), National League (NL) and the American League (AL), with 29 in the United States and 1 in Canada. MLB i ...
catcher who wore the number 09 for several years, is the only
major professional sports league player to use a
jersey number with a leading zero, not counting several who have worn the number 00 (he wore the extra zero to avoid complications with his catcher's pads, allowing the back strap to run between the numbers instead of over a single digit 9).
Dennis Rodman had requested the number 01 when he joined the
Chicago Bulls
The Chicago Bulls are an American professional basketball team based in Chicago. The Bulls compete in the National Basketball Association (NBA) as a member of the Central Division of the Eastern Conference. The team was founded on January 16 ...
(as his usual number 10 had already been retired), but the
National Basketball Association
The National Basketball Association (NBA) is a professional basketball league in North America composed of 30 teams (29 in the United States and 1 in Canada). The NBA is one of the major professional sports leagues in the United States and Ca ...
forbade it, and Rodman instead wore 91.
In most countries other than the United States, numbers between 0 and 1, expressed as a decimal, include a zero before the decimal point (e.g. 0.64 or in many countries 0,64) while in the United States this zero is often omitted (.64).
Advantages
Collation
Leading zeros are used to make ascending order of numbers correspond with
alphabetical order
Alphabetical order is a system whereby character strings are placed in order based on the position of the characters in the conventional ordering of an alphabet. It is one of the methods of collation. In mathematics, a lexicographical order is ...
: e.g., 11 comes alphabetically before 2, but after 02. (See, e.g.,
ISO 8601
ISO 8601 is an international standard covering the worldwide exchange and communication of date and time-related data. It is maintained by the International Organization for Standardization (ISO) and was first published in 1988, with updates in ...
.) This does not work with
negative number
In mathematics, a negative number is the opposite (mathematics), opposite of a positive real number. Equivalently, a negative number is a real number that is inequality (mathematics), less than 0, zero. Negative numbers are often used to represe ...
s, 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
Pharmacy is the science and practice of discovering, producing, preparing, dispensing, reviewing and monitoring medications, aiming to ensure the safe, effective, and affordable use of medication, medicines. It is a miscellaneous science as it ...
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
In a ratio scale based on powers of ten, the order of magnitude is a measure of the nearness of two figures. Two numbers are "within an order of magnitude" of each other if their ratio is between 1/10 and 10. In other words, the two numbers are wi ...
.
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.
Zero as a prefix
A prefix
0
is used in
C to specify string representations of
octal
Octal (base 8) is a numeral system with eight as the base.
In the decimal system, each place is a power of ten. For example:
: \mathbf_ = \mathbf \times 10^1 + \mathbf \times 10^0
In the octal system, each place is a power of eight. For ex ...
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
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language".
Perl was developed ...
,
Ruby
Ruby is a pinkish-red-to-blood-red-colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sapph ...
,
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
The decimal numeral system (also called the base-ten positional numeral system and denary or decanary) is the standard system for denoting integer and non-integer numbers. It is the extension to non-integer numbers (''decimal fractions'') of th ...
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
{{DEFAULTSORT:Leading Zero
Computer data
Digital electronics
Numeral systems
0 (number)