paul mak
> I am looking for the source code/algorithm of calculation of hkid
>card check digit.
Hi Paul,
You may try the following algorithm :
Calculation of the check digit:
===============================
For example, the HKID no. is A123456
^^
1) If there is a "blank" before "A", just like our case, it is treated
as a "]" (91 in ASCII)
2) For other characters, just apply the ASCII value of that character
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
in the following formula. (A=65, B=66, .....)
3) A = 65 in ASCII
Total = 91*9 + 65*8 + 1*7 + 2*6 + 3*5 + 4*4 + 5*3 + 6*2
^^
"]" in ASCII
= 1416
MOD(total) with 11 ==> 1416 / 11 = 128 ... 8 (Remainder)
Check digit = 11 - Remainder = 11 - 8 = 3
Therefore the HKID no. is A123456(3)
Check on yourself 'n see if it helps...
Philip Lam
(NOSPAM....@hk.super.net)
<< Remove "NOSPAM." when reply >>