Post Reply 
checkdigit calculation for HP-17b
07-28-2015, 09:51 PM
Post: #20
RE: checkdigit calculation for HP-17b
(07-28-2015 08:28 PM)Thomas Klemm Wrote:  This gives us:
Code:
v[2] := (9×cpf[1] + 8×cpf[2] + 7×cpf[3] + 6×cpf[4] + 5×cpf[5] + 4×cpf[6] + 3×cpf[7] + 2×cpf[8] + 1×cpf[9]) mod 11

Thanks, Thomas!

I wonder why they use a somewhat more complicate method here, that is, multiplications of the sums by 10 being required before the final mod 11 operation, not to mention the appending of the first checking digit to the number before computing the second checking digit. I haven't even tried to implement that method on the 17Bii, but it appears to me the resulting equation would be much longer.

(07-28-2015 08:28 PM)Thomas Klemm Wrote:  But then you will say that v[1] wasn't calculated correctly:
Code:
v[1] := v[1] mod 11
v[1] := v[1] mod 10

Thus in case that v[1] = 10 we will get 0 instead of 10.
This is corrected with this step in your program:
Code:
  t:=t+9*((s Mod 11) div 10);

Yes, I discovered that by examining a few wrong results (adding 9 to the first sum before mod 11 would always do in those cases). Another version uses the following instead, but that would make for a longer 17Bii equation, I think.

Code:
  if (s Mod 11)=10 then
    t:=t+9;

Regards,

Gerson.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: checkdigit calculation for HP-17b - Gerson W. Barbosa - 07-28-2015 09:51 PM



User(s) browsing this thread: 6 Guest(s)