Mega Code Archive

 
Categories / Delphi / Algorithm Math
 

How to compute a Modul 10 check number

Title: How to compute a Modul 10 check number function modula10(zahl: Int64): Int64; Stelle Wert Wichtung Produkt 1 4 * 3 12 2 2 * 1 2 3 0 * 3 0 4 5 * 1 5 5 4 * 3 12 6 5 * 1 5 7 0 * 3 0 ------- Summe 36 Summe / 10(Modul) = 3 Rest 6 10(Modul) - 6(Rest) = 4 - var wert: Longint; multi: Word; begin multi := 3; wert := 0; repeat wert := wert + (zahl - trunc(zahl / 10) * 10) * multi; if multi = 3 then multi := 1 else multi := 3; zahl := trunc(zahl / 10); until zahl = 0; Result := 10 - (wert - trunc(wert / 10) * 10); //Wenn if Result = 10 then Result := 0; end; function ismodula10(zahl: Int64): Boolean; begin if modula10(trunc(zahl / 10)) = zahl - (trunc(zahl / 10) * 10) then Result := True else Result := False; end;