Talk:CUSIP
From Wikipedia, the free encyclopedia
I'm having trouble with the check digit algorithm:
Consider Google: CUSIP 38259P102. Expanding P = 25 (16 + 9) gives 3825925102
We have: (3, 2, 9, 5, 0) and (8, 5, 2, 1) Since the last digit is in the first group we double that: 6 + 4 + (1 + 8) + (1 + 0) + 0 + 8 + 5 + 2 + 1 = 36
36 mod 10 = 6, 10 - 6 = 4.
But the check digit is 2.
Any thoughts?
24.215.233.224 03:35, 26 July 2007 (UTC) GR
- The characters have to be separated before letters are expanded into their numeric equivalents:
38259P10 = (3 + 2 + 9 + 1) + 2 * (8 + 5 + P + 0) = (3 + 2 + 9 + 1) + 2 * (8 + 5 + (2 + 5) + 0) = (3 + 2 + 9 + 1) + ((1 + 6) + (1 + 0) + (4 + (1 + 0)) + 0) = 15 + 13 = 28
- and (10 - 28) mod 10 = 2. This is different from the ISIN check digit algorithm, in which the letter expansion occurs before alternate digits are collected. 67.87.115.207 06:13, 12 October 2007 (UTC)
Are CUSIP's ever reused?
Would it be possible to use language other than Perl for the code sample ? Should we consider Java, ECMA script or even Cobol ? Although these languages may be more "bloated" than Perl, they may be more friendly and may actually be usable. Regards 68.192.150.202 01:04, 25 May 2007 (UTC)
We may be able to make the code more compact since the bNum is the same as
aNum except for the 2x multiply. So we may be able to do something like:
... $tt += aNum($t[2*$i], 1); $tt += aNum($t[2*$i+1], 2); ... sub aNum{ my $a = shift; my $x = $a; $x = ord($a)-ord('A')+10 if $a =~ /[A-Z]/; my $b = shift; $x = $b*$x; my $d = floor($x/10); return $x-$d*10+$d; }
- Problem solved. 164.55.254.106 18:03, 24 July 2007 (UTC)
[edit] Removed code samples
I have removed the code samples. Whenever these are added to generic articles like these, they tend to turn into requires for "enter favorite language here". I can see this happened above. Code for CUSIP formatting is easy to find on the 'net, that's the proper place for it. I notice links to examples already exist. Maury 20:05, 15 October 2007 (UTC)