Gs1CheckDigit

GS1 mod-10 check digit, shared by GTIN-8/12/13/14, SSCC, GLN and other numeric GS1 keys.

Starting from the rightmost digit of the key body, digits are weighted 3, 1, 3, 1…; the check digit is the amount needed to reach the next multiple of ten.

Functions

Link copied to clipboard
fun append(body: String): String

Returns body with its check digit appended.

Link copied to clipboard
fun compute(body: String): Int

Computes the check digit for body, the key digits without the check digit.

Link copied to clipboard

Returns true if key is all digits and its last digit is the correct check digit.