Sei sulla pagina 1di 8

Modulus 11

Self-Check
Digits
Some numbers are more
important to get right during
data entry than others.
In transaction processing
applications, transposing or
mis-typing digits in account
numbers can result in applying
debits or credits to the wrong
person's account.
To reduce the possibility of
such mistakes, account
numbers can be crafted in such
a way that simple errors are
detected. This is done by
calculating a single-digit value
based on the account number,
and then appending that digit
to the base number to arrive at
a final account number. When
this account number is entered,
the check digit value is
stripped off and recalculated.
If the supplied value does not
match the recalculated value,
the account number is rejected.
One common scheme for
generating self-check digits,
described here, is called
Modulus 11 Self-Check. There
are various versions of this,
which differ in the weightings
used; this document describes
the one used by IBM on the
iSeries (formerly AS/400,
System/38) and in the 5250
series of terminal devices.
Each digit in the base number
is assigned a multiplication
factor. The factors are

assigned from right to left,
starting at two and counting
up. For numbers longer than
six digits, the factors restart at
two after seven is reached. The
product of each digit and its
factor is calculated, and the
products summed, as follows:

Base number : 1 6
7 7 0 3 6
2 5
Factor . . : 4 3
2 7 6 5 4
3 2
--- --- --
- --- --- --- --- --
- ---
4 + 18 +
14 + 49 + 0 + 15 + 24 +
6 + 10 = 140

The sum of the products is
divided by the prime number
11. The remainder is
inspected, and:
if the remainder is
zero, the check digit is
also zero.
if the remainder is one,
the check digit is
ambiguous, and the
base number should
not be used as an
account number.
for all others, the
remainder is subtracted
from 11. The result is
the check digit.
To continue the example, 140
divided by 11 is 12, with a
remainder of 8. 11 minus 8 is
3, so 3 is the modulus 11
check digit for 167703625.

Divide sum of products by
11 : 140 / 11 = 12
remainder 8
Confirm . . . . . . . .
. . : 12 * 11 = 132
140 - 132 = 8
Subtract remainder from
11 . : 11 - 8 = 3

The self-checking account
number becomes 1677036253.
Examples of the validation
procedure:

Acct # Base ? Sum of
Products
Remainder Ck Digit OK
------ ----- - -------
-------------------------
---------- -------- ---
010006 01000 6 0x6 +
1x5 + 0x4 + 0x3 + 0x2 =
5 5/11 r=5 11-5 = 6 Yes
010022 01002 2 0x6 +
1x5 + 0x4 + 0x3 + 2x2 =
9 9/11 r=9 11-9 = 2 Yes
010057 01005 7 0x6 +
1x5 + 0x4 + 0x3 + 5x2 =
15 15/11 r=4 11-4 = 7
Yes
010066 01006 6 0x6 +
1x5 + 0x4 + 0x3 + 6x2 =
17 17/11 r=6 11-6 = 5 NO
010091 01009 1 0x6 +
1x5 + 0x4 + 0x3 + 9x2 =
23 23/11 r=1 --n/a--- NO

The simple modulus 11 self-
check digit calculator below
demonstrates the results
obtained by the above
algorithm:
Check Digit
Calculator
Starting
number
(max 16
digits) :


Number
to
generate

Generate

(max
128) :
The PHP code that implements
this calculator:

/* Append modulus 11
check digit to supplied
string of digits. */
function GenMOD11(
$base_val )
{
$result = "";
$weight = array( 2, 3,
4, 5, 6, 7,
2, 3,
4, 5, 6, 7,
2, 3,
4, 5, 6, 7,
2, 3,
4, 5, 6, 7 );

/* For convenience,
reverse the string and
work left to right. */
$reversed_base_val =
strrev( $base_val );
for ( $i = 0, $sum =
0; $i < strlen(
$reversed_base_val );
$i++ )
{
/* Calculate
product and accumulate.
*/
$sum += substr(
$reversed_base_val, $i, 1
) * $weight[ $i ];
}

/* Determine check
digit, and concatenate to
base value. */
$remainder = $sum %
11;
switch ( $remainder )
{
case 0:
$result = $base_val
. 0;
break;
case 1:
$result = "n/a";
break;
default:
$check_digit = 11 -
$remainder;
$result = $base_val
. $check_digit;
break;
}

return $result;
}



Copyright 1996, 2014 Marcus Redivo. All rights reserved.
Last modified on Sat Dec 4 22:07:48 2010
http://www.eclectica.ca/howto/modulus-11-self-check.php
check digit
A numeric digit used to ensure that account numbers are entered accurately into the computer. Using
a formula, a digit is calculated from each new account number, which is thenmade part of that number
, either at the end, the beginning or somewhere in the middle of the number.

When an account number with the check digit is entered, the data entry program recalculates the che
ck digit and compares it to the check digit entered. If the digits are not equal, theaccount number is co
nsidered invalid.
http://encyclopedia2.thefreedictionary.com/self-checking+digit
http://www.gs1.org/barcodes/support/check_digit_calculator
http://www.gs1us.org/resources/tools/check-digit-calculator
http://en.wikipedia.org/wiki/Check_digit
http://blog.cantab-ip.com/blog/2014/01/20/new-format-for-singapore-ip-application-numbers-at-
ipos/
http://web.archive.org/web/20090603232957/http://www.academic.marist.edu/mwa/idsn.htm

Identification Numbers and Check Digit Schemes
Preliminary Activity: Create a list of at least five different types of identifying numbers
taken from a variety of different sources (e.g., product labels, magazines, and book covers).
Look at all the identification numbers collected, paying special attention to the lengths of
each number, the types of characters used, and other defining characteristics. Write a short
summary of your findings.

Identification numbers are used to identify individual items, specific products, people,
accounts, or documents. Social security numbers, driver license numbers, credit card
numbers, International Standard Book Numbers (ISBN), Universal Product Codes (UPC),
and bank account numbers are all examples of identification numbers. In addition, numbers
are used to identify passports, US Postal money orders, UPS packages, library books,
merchandise, and many other items.
Identification numbers are used for a variety of purposes. Not only are they used for easy
identification of products, documents, or accounts, but for tracking and inventory purposes.
For example, UPS numbers are not only used to identify specific packages, but also to track
the packages. Each package that a customer sends is assigned a number so that the customer
knows when the package was picked up, where it is at any point in time, and when the
package is delivered. UPCs, found on most products, are used in a variety of ways. First of
all, a UPC not only identifies the product, but also the type of the product and its
manufacturer. Each store associates a price with the UPC that appears on the cash register
when the product's bar code is scanned at the check-out counter. Stores also use UPCs to
keep track of inventory.
An identification number usually takes the form of a string of digits, letters, symbols, or
some combination of them. A digit is a number 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9, and a symbol is
an object such as *, /, #, & or $. Together, digits, letters, and symbols, form the characters
that are used to create identification numbers.
Every day, identification numbers are presented over the phone, copied onto documents,
scanned and entered into computers, or transmitted by some other method. Each time this
happens, there is a chance that one or more digits in the number will change or move when it
is transmitted from one location to the other. For example, the UPC 0-53600-10054-0 on a
product could be scanned into the computer as 0-53600-10059-0 or 0-53600- 10045-0. In
either case, an error in the number has occurred. In addition, less than honest individuals
sometimes attempt to forge certain identification numbers for personal profit.
It is important to ensure that identification numbers are transmitted correctly, and in
certain cases, not forged. Transmission errors can occur when bar codes are scanned
incorrectly, when numbers are written or typed in the wrong order, or when phonetic
mistakes (eg: one person says ``sixteen" and the other hears ``sixty") are made. Table #1 lists
the most common types of errors and their relative frequency.

Table #1


All this motivates the following goal: To develop methods that will recognize when an
identification number has been transmitted incorrectly! These methods, called check digit
schemes, are not that difficult to develop. In fact, there are even algorithms that identify
errors and then correct the error that was made.
Most check digit schemes append an extra digit or digits, called a check digit(s), to the
number generated for a product, document, etc, and then use that digit(s) to check for errors
after the number has been transmitted. The check digit can appear in any position in the
number. However, it is often appended to the end of the number and is the last digit(s) in the
identification number.






Paper Assignment: You are employed by an organization that wants to use a check digit
scheme. At this point, you are familiar with a variety of schemes. An initial survey done by
the company has reduced the choices down to two schemes, the ISBN and Verhoeff
schemes. Your colleague recommends the ISBN scheme, but you believe that the Verhoeff
scheme is better for the organization. Write a report that not only recommends the Verhoeff
scheme but also refutes your colleague's earlier recommendation.

To do this, compare both schemes in a report called a feasibility study, paying attention to
the following factors:
ease of use (the length, time involved with, and complexity of the calculations)
strength (in terms of the errors it can detect)
flexibility (the ISBN scheme is designed for an identification number of a fixed
length while the Verhoeff scheme can be manipulated and adjusted to an
identification number of any length).
At the end of this comparison, you should recommend the Verhoeff scheme and state
your reasons for doing so.

Paper Assignment: You are employed by an organization that wants to use a check digit
scheme. At this point, you are familiar with a variety of schemes. An initial survey done by
the company has reduced the choices down to two schemes, the IBM and Verhoeff schemes.
Your colleague recommends the IBM scheme, but you believe that the Verhoeff scheme is
better for the organization. Write a report that not only recommends the Verhoeff scheme but
also refutes your colleague's earlier recommendation.

To do this, compare both schemes in a report called a feasibility study, paying attention to
the following factors:
ease of use (the length, time involved with, and complexity of the calculations)
strength (in terms of the errors it can detect)
flexibility (both the IBM and Verhoeff schemes are designed for an identification
number of any length).
At the end of this comparison, you should recommend the Verhoeff scheme and state
your reasons for doing so.
http://web.archive.org/web/20090603232957/http://www.academic.marist.edu/mwa/idsn.htm


http://www.gwii.com/check-digit-calculator.html
http://blog.cantab-ip.com/blog/2014/01/20/new-format-for-singapore-ip-application-numbers-at-
ipos/
https://www.questia.com/library/journal/1P3-1485290341/identification-numbers-and-the-
mathematics-of-check
https://www.uu.edu/dept/math/SeniorPapers/01-02/Oldham.pdf

Potrebbero piacerti anche