A Serial Number is unique number that that is one of a series assigned for identification which varies from it's successor or predecessor by a fixed discreet integer value. Common usage has expanded the term to refer to any unique alphanumeric identifier for one of a large set of objects, however in data processing and allied fields in computer science, the distinction between serial and nominal numbers is an important one.
When considered as serial numbers no value has any particular significance, there is no minimum or maximum serial number, every value has a successor and predecessor. Serial numbers are formed from non-negative integers from a finite subset of the range of all integer values. The lowest integer in every subset used for this purpose is zero
In computer science applications, the maximum is always one less than a power of two.
To define a serial number to be used in this way, the size of the serial number space must be given. This value, called "SERIAL_BITS", gives the power of two which results in one larger than the largest integer corresponding to a serial number value. This also specifies the number of bits required to hold every possible value of a serial number of the defined type. The operations permitted upon serial numbers are defined in the following section.
Operations on serial numbers (sequence space arithmetic)
Only two operations are defined upon serial numbers, addition of a positive integer of limited range, and comparison with another serial number.
Addition
Serial numbers may be incremented by the addition of a positive integer n, where n is taken from the range of integers [0 .. (2^(SERIAL_BITS - 1) - 1)]. For a sequence number s, the result of such an addition, s', is defined as
s' = (s + n) modulo (2 ^ SERIAL_BITS)
where the addition and modulus operations here act upon values that are non-negative values of unbounded size in the usual ways of integer arithmetic.
Addition of a value outside the range [0 .. (2^(SERIAL_BITS - 1) - 1)] is undefined.
Comparison
Any two serial numbers, s1 and s2, may be compared. The definition of the result of this comparison is as follows.
For the purposes of this definition, consider two integers, i1 and i2, from the unbounded set of non-negative integers, such that i1 and s1 have the same numeric value, as do i2 and s2. Arithmetic and comparisons applied to i1 and i2 use ordinary unbounded integer arithmetic.
Then, s1 is said to be equal to s2 if and only if i1 is equal to i2, in all other cases, s1 is not equal to s2.
s1 is said to be less than s2 if, and only if, s1 is not equal to s2, and
(i1 < i2 and i2 - i1 < 2^(SERIAL_BITS - 1)) or (i1 > i2 and i1 - i2 > 2^(SERIAL_BITS - 1))
s1 is said to be greater than s2 if, and only if, s1 is not equal to s2, and
(i1 < i2 and i2 - i1 > 2^(SERIAL_BITS - 1)) or (i1 > i2 and i1 - i2 < 2^(SERIAL_BITS - 1))
Note that there are some pairs of values s1 and s2 for which s1 is not equal to s2, but for which s1 is neither greater than, nor less than, s2. An attempt to use these ordering operators on such pairs of values produces an undefined result.
The reason for this is that those pairs of values are such that any simple definition that were to define s1 to be less than s2 where (s1, s2) is such a pair, would also usually cause s2 to be less than s1, when the pair is (s2, s1). This would mean that the particular order selected for a test could cause the result to differ, leading to unpredictable implementations.
While it would be possible to define the test in such a way that the inequality would not have this surprising property, while being defined for all pairs of values, such a definition would be unnecessarily burdensome to implement, and difficult to understand, and would still allow cases where
s1 < s2 and (s1 + 1) > (s2 + 1)
which is just as non-intuitive.
Thus the problem case is left undefined, implementations are free to return either result, or to flag an error, and users must take care not to depend on any particular outcome. Usually this will mean avoiding allowing those particular pairs of numbers to co-exist.
The relationships greater than or equal to, and less than or equal to, follow in the natural way from the above definitions.
These definitions give rise to some results of note.
Corollary 1
For any sequence number s and any integer n such that addition of n to s is well defined, (s + n) >= s. Further (s + n) = s only when n = 0, in all other defined cases, (s + n) > s.
Corollary 2
If s' is the result of adding the non-zero integer n to the sequence number s, and m is another integer from the range defined as able to be added to a sequence number, and s" is the result of adding m to s', then it is undefined whether s" is greater than, or less than s, though it is known that s" is not equal to s.
Corollary 3
If s" from the previous corollary is further incremented, then there is no longer any known relationship between the result and s.
Corollary 4
If in corollary 2 the value (n + m) is such that addition of the sum to sequence number s would produce a defined result, then corollary 1 applies, and s" is known to be greater than s.
A trivial example
The simplest meaningful serial number space has SERIAL_BITS = 2. In this space, the integers that make up the serial number space are 0, 1, 2, and 3. That is, 3 = 2^SERIAL_BITS - 1.
In this space, the largest integer that it is meaningful to add to a sequence number is 2^(SERIAL_BITS - 1) - 1, or 1.
Then, as defined 0+1 = 1, 1+1 = 2, 2+1 = 3, and 3+1 = 0. Further, 1 > 0, 2 > 1, 3 > 2, and 0 > 3. It is undefined whether 2 > 0 or 0 > 2, and whether 1 > 3 or 3 > 1.
A slightly larger example
Consider the case where SERIAL_BITS = 8. In this space the integers that make up the serial number space are 0, 1, 2, ... 254, 255. 255 = 2^SERIAL_BITS - 1.
In this space, the largest integer that it is meaningful to add to a sequence number is 2^(SERIAL_BITS - 1) - 1, or 127.
Addition is as expected in this space, for example: 255+1 = 0, 100+100 == 200, and 200+100 = 44.
Comparison is more interesting, 1 > 0, 44 > 0, 100 > 0, 100 > 44, 200 > 100, 255 > 200, 0 > 255, 100 > 255, 0 > 200, and 44 > 200.
Note that 100+100 > 100, but that (100+100)+100 < 100. Incrementing a serial number can cause it to become "smaller". Of course, incrementing by a smaller number will allow many more increments to be made before this occurs. However this is always something to be aware of, it can cause surprising errors, or be useful as it is the only defined way to actually cause a serial number to decrease.
The pairs of values 0 and 128, 1 and 129, 2 and 130, etc, to 127 and 255 are not equal, but in each pair, neither number is defined as being greater than, or less than, the other.
It could be defined (arbitrarily) that 128 > 0, 129 > 1, 130 > 2, ..., 255 > 127, by changing the comparison operator definitions, as mentioned above. However note that that would cause 255 > 127, while (255 + 1) < (127 + 1), as 0 < 128. Such a definition, apart from being arbitrary, would also be more costly to implement.
Ref: Serial Number Arithmetic from RFC1982.
Estimating the population size using serial numbers
If there are items whose serial numbers is part of a sequence of consecutive numbers and you take n number of random samples of the items. You can determine the population of items "in the wild".
To do so, calculate the difference between the largest serial number and the smallest serial number in your sample. The expected population size of the item is that difference divided by the expected proportion.
For example:
You take 4 random samples. The serial numbers are 2,7,34,13. Thus the difference is 34-2=32. The expected proportion is 0.6 The expected population size is 32 / 0.6 = 53 and the standard deviation of the expected proportion is 0.2
numofsamples = 2 proportion = 0.333 std_dev = 0.236 numofsamples = 3 proportion = 0.500 std_dev = 0.224 numofsamples = 4 proportion = 0.600 std_dev = 0.200 numofsamples = 5 proportion = 0.667 std_dev = 0.178 numofsamples = 6 proportion = 0.714 std_dev = 0.160 numofsamples = 7 proportion = 0.750 std_dev = 0.144 numofsamples = 8 proportion = 0.778 std_dev = 0.132 numofsamples = 9 proportion = 0.800 std_dev = 0.121 numofsamples = 10 proportion = 0.818 std_dev = 0.111 numofsamples = 11 proportion = 0.833 std_dev = 0.103 numofsamples = 12 proportion = 0.846 std_dev = 0.097 numofsamples = 13 proportion = 0.857 std_dev = 0.090 numofsamples = 14 proportion = 0.867 std_dev = 0.085 numofsamples = 15 proportion = 0.875 std_dev = 0.080
Applications of serial numbering
Serial numbers are valuable in quality control, as once a defect is found in the production of a particular batch of product, the serial number will quickly identify which units are affected. Serial numbers are also used as a deterrent against theft and counterfeit products in that serial numbers can be recorded, and stolen or otherwise irregular goods can be identified.
Many computer programs come with serial numbers, often called "CD keys," and the installers often require the user to enter a valid serial number to continue. These numbers are verified using a certain algorithm to avoid usage of counterfeit keys.
Serial numbers also help track down counterfeit currency, because in some countries each banknote has a unique serial number.
The ISSN or International Standard Serial Number seen on magazines and other periodicals, an equivalent to the ISBN applied to books, is serially assigned but takes its name from the library science use of serial to mean a periodical.
Certificates and Certificate Authorities (CA) are necessary for widespread use of cryptography. These depend on applying mathematically rigorous serial numbers and serial number arithmetic
The term "serial number" is also used in military formations as an alternative to the expression "service number".
See also
References
William W. Plummer, "Sequence Number Arithmetic" BB&N Inc, September 1978.
R. Elz and R. Bush, "Serial Number Arithmetic" Network Working Group, August 1996