Algori...MXX_005(3pm)

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

πŸ’– CheckDigits::MXX_005 πŸ’–

okay bestie, so this is the CheckDigits::MXX_005 page from the User Contributed Perl Documentation β€” it's the whole entire lore for computing check digits for ESR9 (CH) ✨ no cap, that's literally what it does.


🌸 SYNOPSIS 🌸

fr fr here's the vibe in code:

use Algorithm::CheckDigits;

$esr = CheckDigits('esr9');

if ($esr->is_valid('123456786')) {
      # do something
}

$cn = $esr->complete('12345678');
# $cn = '123456786'

$cd = $esr->checkdigit('123456786');
# $cd = '6'

$bn = $esr->basenumber('123456786');
# $bn = '12345678'

✨ DESCRIPTION ✨

🧚 ALGORITHM

ok so the math is giving very demure, very mindful, here's how it goes:

  1. Digits get processed left to right. For the first digit, the balance is 0 β€” that's just the starting rule, periodt.
  2. The new balance gets pulled straight out of the balance table, using the current balance as the row and the digit as the column. That's it, that's the whole lookup.
  3. The check digit? It's the difference from the last balance to 10, taken modulo 10. Slay.

πŸ‘‘ 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 up above ☝️

Returns false otherwise. That's the whole deal.

complete($number)

The check digit for $number gets computed and concatenated onto the end of $number. Iconic behavior honestly.

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. Same energy, different method.


πŸŽ€ EXPORT

None by default. Not a single thing, bestie. Nothing gets exported unless you ask. 🫢


πŸ’… AUTHOR

Mathias Weidner, "<mamawe@cpan.org>" β€” the main character who wrote this, we stan. πŸ‘‘


🌈 SEE ALSO

  • perl
  • CheckDigits
  • www.pruefziffernberechnung.de

⭐ lowkey important: always check your work against the actual algorithm, bestie β€” don't just trust the vibe check. πŸ¦‹

and that's the whole page, fr fr. this was perl v5.36.0, dated 2022-10-13, and yes the title is literally truncated to Algori...MXX_005(3pm) in the header because old-school manpage headers stay tiny. periodt. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from