Algori...M11_010(3pm)

๐Ÿ“ฆ
version 1.3.6 ยท 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

โœจ NAME โœจ

CheckDigits::M11_010 โ€” bestie, this is the module that computes check digits for the AHV number (CH) ๐Ÿ‡จ๐Ÿ‡ญ๐Ÿ’… (it lives in Algorithm::CheckDigits, and you'll also see it hanging out in the perl man pages as Algori...M11_010(3pm), user-contributed Perl documentation energy ๐Ÿ‘‘)


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

use Algorithm::CheckDigits;

$ahv = CheckDigits('ahv_ch');

if ($ahv->is_valid('123.45.678.113')) {
      # do something
}

$cn = $ahv->complete('123.45.678.11');
# $cn = '123.45.678.113'

$cd = $ahv->checkdigit('123.45.678.113');
# $cd = '3'

$bn = $ahv->basenumber('123.45.678.113');
# $bn = '123.45.678.11';

okay so literally just use it, grab CheckDigits('ahv_ch'), and go off ๐Ÿ’–


๐ŸŒธ DESCRIPTION ๐ŸŒธ

๐Ÿงฎ ALGORITHM

no cap, the math is giving very "trust the process":

  1. Beginning left, every digit is weighted with 5,4,3,2,7,6,5,4,3,2. โœจ
  2. The weighted digits are added. ๐Ÿ”ฅ
  3. The sum from step 2 is taken modulo 11. ๐Ÿ’ซ
  4. The checkdigit is 11 minus the sum from step 3. Is the difference 10, the number won't be taken. If the difference is 11, the checkdigit is 0. ๐Ÿซถ

๐Ÿ’… METHODS

  • is_valid($number) โ€” Returns true only if $number consists solely of numbers and dots and the rightmost digit is a valid check digit according to the algorithm given above. Returns false otherwise. (so basically a vibe check, but for check digits ๐Ÿ˜Œ)
  • complete($number) โ€” The check digit for $number is computed and appended the end of $number. Returns the complete number with check digit or '' if $number does not consist solely of digits and dots.
  • basenumber($number) โ€” Returns the basenumber of $number if $number has a valid check digit. Return '' otherwise. ๐ŸŽ€
  • checkdigit($number) โ€” Returns the check digits of $number if $number has valid check digits. Return '' otherwise. โญ

๐Ÿ“ฆ EXPORT

None by default. (she's lowkey shy like that ๐Ÿ™ˆ)


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Mathias Weidner, <mamawe@cpan.org> ๐Ÿ’œ


๐ŸŒˆ SEE ALSO ๐ŸŒˆ

perl, CheckDigits, www.pruefziffernberechnung.de, ๐Ÿงš


and that's the whole page bestie, slay ๐Ÿ’–โœจ โ€” this iconic little number came to you via perl v5.36.0, dated 2022-10-13, straight outta the Algori...M11_010(3pm) era. periodt. ๐ŸŽ€

๐Ÿ“ฆ where this page comes from