Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@eight
Created November 6, 2009 01:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eight/227608 to your computer and use it in GitHub Desktop.
Save eight/227608 to your computer and use it in GitHub Desktop.
function m10w31(code: string): integer;
/**
Delphi版 モジュラス10ウエィト3のチェックデジット計算。
*/
var
i,w,sum: integer;
begin
w := 3;
sum := 0;
for i := length(code) downto 1 do
begin
sum := sum + strtoint(code[i]) * w;
if w = 3 then w := 1
else w := 3;
end;
Result := sum mod 10;
if Result<>0 then Result := 10 - Result;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment