Algori...M16_001(3pm)

πŸ“¦
version 1.3.6 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– CheckDigits::M16_001 β€” the ISAN check digit page (yes, that Algori...M16_001(3pm) one) πŸ’–

okay bestie, gather round, because this is a Perl module page and it's genuinely so cute and useful. this one lives in the Perl docs as Algori...M16_001(3pm) β€” you know, the user-contributed Perl documentation corner. it's all about computing check digits for ISAN 🌸


✨ NAME ✨

CheckDigits::M16_001 β€” computes check digits for ISAN πŸ’…


🌈 SYNOPSIS 🌈

look at her. so clean. so iconic.

  use Algorithm::CheckDigits;

  $isan = CheckDigits('isan');

  if ($isan->is_valid('123A567B8912E01A')) {
        # do something
  }

  $cn = $isan->complete('123A567B8912E01');
  # $cn = '123A567B8912E01A'

  $cd = $isan->checkdigit('123A567B8912E01A');
  # $cd = '4'

  $bn = $isan->basenumber('123A567B8912E01A');
  # $bn = '123A567B8912E01'

like. the math is mathing and the vibes are vibing. πŸ¦‹


🧠 DESCRIPTION 🧠

πŸ”₯ ALGORITHM πŸ”₯

bestie listen, this is the whole recipe and it is giving hexagons:

  1. a(1) = 16

b(i) = a(i) % 17 +d(i), where d(i) is the decimal value of the hexdigit at position i.

c(i) = b(i) % 16

a(i) = c(i-1) * 2, for i greater than 1

  1. Beginning left for each i = 1..16, a, b, c are computed.
  2. The check digit is the value for d(16) where c(16) equals 1.
  3. The check digit is appended as hexadecimal value to the number.
not me reading a and b and c four times to make sure i kept every single one 😭 they're all there, promise. no cap.

🫢 METHODS 🫢

  • is_valid($number) β€” returns true only if $number consists solely of numbers and the last digit is a valid check digit according to the algorithm given above. Returns false otherwise,
  • complete($number) β€” the check digit for $number is computed and concatenated to the end of $number. Returns the complete number with check digit or '' if $number does not consist solely of digits and spaces.
  • basenumber($number) β€” returns the basenumber of $number if $number has a valid check digit. Return '' otherwise.
  • checkdigit($number) β€” returns the checkdigit of $number if $number has a valid check digit. Return '' otherwise.

πŸ“¦ EXPORT πŸ“¦

None by default.

(thats it. thats the whole export section. minimalism queen πŸ‘‘)


πŸ’œ AUTHOR πŸ’œ

Mathias Weidner, "<mamawe@cpan.org>"


πŸŽ€ SEE ALSO πŸŽ€

perl, CheckDigits, www.pruefziffernberechnung.de.


okay and the little sign-off at the bottom of the page says it's perl v5.36.0, dated 2022-10-13 β€” so yeah, this page has been serving looks since then. go forth and validate those ISANs, bestie, you've got this fr fr πŸ’–βœ¨πŸŒΈ

πŸ“¦ where this page comes from