Leading zero

Last updated

A leading zero is any 0 digit that comes before the first nonzero digit in a number string in positional notation. [1] For example, James Bond's famous identifier, 007, has two leading zeros. [2] Any zeroes appearing to the left of the first non-zero digit (of any integer or decimal) do not affect its value, and can be omitted (or replaced with blanks) with no loss of information. [3] Therefore, the usual decimal notation of integers does not use leading zeros except for the zero itself, which would be denoted as an empty string otherwise. [4] However, in decimal fractions strictly between −1 and 1, the leading zeros digits between the decimal point and the first nonzero digit are necessary for conveying the magnitude of a number and cannot be omitted, [1] while trailing zeros – zeros occurring after the decimal point and after the last nonzero digit – can be omitted without changing the meaning.

Contents

Occurrence

A municipal bridge number with a leading zero Turnov, most pres Libunku c. 011.jpg
A municipal bridge number with a leading zero

Often, leading zeros are found on non-electronic digital displays or on such electronic ones as seven-segment displays, that contain fixed sets of digits. These devices include manual counters, stopwatches, [5] odometers, [6] and digital clocks. [5] 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 cameras 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. [7] The count leading zeros operation efficiently determines the number of leading zero bits in a machine word. [8]

Leading zeros can have its meaning for various reasons:

A leading zero appears in roulette 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 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 (as his usual number 10 had already been retired), but the National Basketball Association forbade it, and Rodman instead wore 91. [9]

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: 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. [10]

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 numbers, as required by the ANSI C standard for the strtol() function (which converts strings to long integers) in the <stdlib.h> library. [11] 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 2010 (2×101 + 0×100), but rather 208 = 1610 (2×81 + 0×80 = 1×101 + 6×100). 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.

House number in Prague with a leading zero as a prefix indicating a special house number series for recreational and provisional buildings Osada Kazin, evidencni cislo 0359.jpg
House number in Prague with a leading zero as a prefix indicating a special house number series for recreational and provisional buildings

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 distinbuishing text or abbreviation or by color of the sign.

See also

Related Research Articles

<span class="mw-page-title-main">Decimal</span> Number in base-10 numeral system

The decimal numeral system is the standard system for denoting integer and non-integer numbers. It is the extension to non-integer numbers of the Hindu–Arabic numeral system. The way of denoting numbers in the decimal system is often referred to as decimal notation.

<span class="mw-page-title-main">Floating-point arithmetic</span> Computer approximation for real numbers

In computing, floating-point arithmetic (FP) is arithmetic that represents subsets of real numbers using an integer with a fixed precision, called the significand, scaled by an integer exponent of a fixed base. Numbers of this form are called floating-point numbers. For example, 12.345 is a floating-point number in base ten with five digits of precision:

In mathematics and computing, the hexadecimal numeral system is a positional numeral system that represents numbers using a radix (base) of sixteen. Unlike the decimal system representing numbers using ten symbols, hexadecimal uses sixteen distinct symbols, most often the symbols "0"–"9" to represent values 0 to 9 and "A"–"F" to represent values from ten to fifteen.

In computer science, an integer is a datum of integral data type, a data type that represents some range of mathematical integers. Integral data types may be of different sizes and may or may not be allowed to contain negative values. Integers are commonly represented in a computer as a group of binary digits (bits). The size of the grouping varies so the set of integer sizes available varies between different types of computers. Computer hardware nearly always provides a way to represent a processor register or memory address as an integer.

<span class="mw-page-title-main">Numeral system</span> Notation for expressing numbers

A numeral system is a writing system for expressing numbers; that is, a mathematical notation for representing numbers of a given set, using digits or other symbols in a consistent manner.

<span class="mw-page-title-main">Number</span> Used to count, measure, and label

A number is a mathematical object used to count, measure, and label. The most basic examples are the natural numbers 1, 2, 3, 4, and so forth. Numbers can be represented in language with number words. More universally, individual numbers can be represented by symbols, called numerals; for example, "5" is a numeral that represents the number five. As only a relatively small number of symbols can be memorized, basic numerals are commonly organized in a numeral system, which is an organized way to represent any number. The most common numeral system is the Hindu–Arabic numeral system, which allows for the representation of any non-negative integer using a combination of ten fundamental numeric symbols, called digits. In addition to their use in counting and measuring, numerals are often used for labels, for ordering, and for codes. In common usage, a numeral is not clearly distinguished from the number that it represents.

Octal is a numeral system with eight as the base.

A computer number format is the internal representation of numeric values in digital device hardware and software, such as in programmable computers and calculators. Numerical values are stored as groupings of bits, such as bytes and words. The encoding between numerical values and bit patterns is chosen for convenience of the operation of the computer; the encoding used by the computer's instruction set generally requires conversion for external use, such as for printing and display. Different types of processors may have different internal representations of numerical values and different conventions are used for integer and real numbers. Most calculations are carried out with number formats that fit into a processor register, but some software systems allow representation of arbitrarily large numbers using multiple words of memory.

Scientific notation is a way of expressing numbers that are too large or too small to be conveniently written in decimal form, since to do so would require writing out an inconveniently long string of digits. It may be referred to as scientific form or standard index form, or standard form in the United Kingdom. This base ten notation is commonly used by scientists, mathematicians, and engineers, in part because it can simplify certain arithmetic operations. On scientific calculators, it is usually known as "SCI" display mode.

A binary number is a number expressed in the base-2 numeral system or binary numeral system, a method for representing numbers that uses only two symbols for the natural numbers: typically "0" (zero) and "1" (one). A binary number may also refer to a rational number that has a finite representation in the binary numeral system, that is, the quotient of an integer by a power of two.

A numerical digit or numeral is a single symbol used alone or in combinations, to represent numbers in a positional numeral system. The name "digit" comes from the fact that the ten digits of the hands correspond to the ten symbols of the common base 10 numeral system, i.e. the decimal digits.

Two's complement is the most common method of representing signed integers on computers, and more generally, fixed point binary values. Two's complement uses the binary digit with the greatest value as the sign to indicate whether the binary number is positive or negative; when the most significant bit is 1 the number is signed as negative and when the most significant bit is 0 the number is signed as positive. As a result, non-negative numbers are represented as themselves: 6 is 0110, zero is 0000, and -6 is 1010. Note that while the number of binary bits is fixed throughout a computation it is otherwise arbitrary.

Dot-decimal notation is a presentation format for numerical data. It consists of a string of decimal numbers, using the full stop (dot) as a separation character.

<span class="mw-page-title-main">Positional notation</span> Method for representing or encoding numbers

Positional notation usually denotes the extension to any base of the Hindu–Arabic numeral system. More generally, a positional system is a numeral system in which the contribution of a digit to the value of a number is the value of the digit multiplied by a factor determined by the position of the digit. In early numeral systems, such as Roman numerals, a digit has only one value: I means one, X means ten and C a hundred. In modern positional systems, such as the decimal system, the position of the digit means that its value must be multiplied by some value: in 555, the three identical symbols represent five hundreds, five tens, and five units, respectively, due to their different positions in the digit string.

In a positional numeral system, the radix or base is the number of unique digits, including the digit zero, used to represent numbers. For example, for the decimal system the radix is ten, because it uses the ten digits from 0 through 9.

A cyclic number is an integer for which cyclic permutations of the digits are successive integer multiples of the number. The most widely known is the six-digit number 142857, whose first six integer multiples are

Bijective numeration is any numeral system in which every non-negative integer can be represented in exactly one way using a finite string of digits. The name refers to the bijection that exists in this case between the set of non-negative integers and the set of finite strings using a finite set of symbols.

In computing, bit numbering is the convention used to identify the bit positions in a binary number.

<span class="mw-page-title-main">Standard Commands for Programmable Instruments</span> Communications protocol for test equipment

The Standard Commands for Programmable Instruments defines a standard for syntax and commands to use in controlling programmable test and measurement devices, such as automatic test equipment and electronic test equipment.

The digits of some specific integers permute or shift cyclically when they are multiplied by a number n. Examples are:

References

  1. 1 2 Miller, Jane E. (2008), The Chicago Guide to Writing about Numbers, University of Chicago Press, p. 276, ISBN   9780226526324 .
  2. Lafore, Robert W. (1987), Microsoft C: programming for the IBM, H.W. Sams, p.  294, ISBN   9780672225154 .
  3. Zegarelli, Mark (2014), Basic Math and Pre-Algebra Workbook For Dummies (2nd ed.), John Wiley & Sons, p. 8, ISBN   9781118828304 .
  4. Flynt, Clif (2012), Tcl/Tk: A Developer's Guide, Elsevier, pp. 752–753, ISBN   9780123847171 .
  5. 1 2 Greene, Jennifer; Stellman, Andrew (2013), Head First C#, O'Reilly Media, Inc., p. 770, ISBN   9781449358884 .
  6. Dueck, Robert; Reid, Ken (2011), Digital Electronics, Cengage Learning, p. 48, ISBN   9781133708964 .
  7. Kuc, Roman (1999), The digital information age: an introduction to electrical engineering, PWS Pub. Co., p.  67, ISBN   9780534953157 .
  8. Dandamudi, Sivarama P. (2005), Guide to RISC Processors: for Programmers and Engineers, Springer, p. 139, ISBN   9780387274461 .
  9. Armour, Terry. Joining Bulls `Almost Like A Storybook' For Former Collins Prep Brown Archived June 4, 2015, at the Wayback Machine . October 6, 1995
  10. Davis, Neil M. (2005). Medical Abbreviations: 26,000 Conveniences at the Expense of Communication and Safety (12th ed.). Warminster, PA: Neil M. Davis Associates. p. 7. ISBN   0931431123.
  11. Kernighan, Brian; Ritchie, Dennis M. (March 1988). The C Programming Language (2nd ed.). Englewood Cliffs, NJ: Prentice Hall. p. 252. ISBN   0-13-110362-8.