Algori...M09_001(3pm)

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

πŸ’– CheckDigits::M09_001(3pm) πŸ’–

okay so bestie, welcome to Algori...M09_001(3pm) β€” it's part of the User Contributed Perl Documentation, and it's literally the page that teaches you how to compute check digits for Euro notes. Euro. Banknotes. Yes we're doing money math, slay. πŸ’Έβœ¨


πŸŽ€ NAME πŸŽ€

CheckDigits::M09_001 β€” compute check digits for Euro notes 🧚


✨ SYNOPSIS ✨

use Algorithm::CheckDigits;

$euro = CheckDigits('euronote');

if ($euro->is_valid('X07738250357')) {
      # do something
}

$cn = $euro->complete('X0773825035');     # $cn = 'X07738250357'

$cd = $euro->checkdigit('X07738250357'); # $cd = '7'

$bn = $euro->basenumber('X07738250357'); # $bn = 'X0773825035'

like, that's the whole vibe. import it, build your checker with CheckDigits('euronote'), and then go off. πŸ’…


πŸ’œ DESCRIPTION πŸ’œ

🌸 ALGORITHM 🌸

okay listen, the algorithm is short and it ate:

  1. Letters are replaced with their position in the alphabet ('A' = 1, ...). so X is not just a letter, it's a number now, periodt. πŸ”€
  2. The total of the digits of all numbers is computed. add it all up, no cap. βž•
  3. This sum is taken modulo 9. classic modulo moment. πŸŒ€
  4. The check digit is the difference between 8 and the number of step 3. so it's 8 minus whatever you got, and that's your last digit. πŸ‘‘
and fr fr, to validate: the last digit of the total of the digits of all numbers (including the check digit) must be 8. that's the vibe check. if it's not 8, it's not valid, sorry bestie. 😭

πŸ¦‹ 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. (that trailing comma is in the original, iconic of it.) 🫢
  • 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. 🧩
  • 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. nothing gets exported unless you ask, and honestly? respecting the personal space. πŸ™ˆ


πŸ‘‘ AUTHOR πŸ‘‘

Mathias Weidner, "<mamawe@cpan.org>" β€” legend behavior, giving us the euro note math for free. πŸ’–


πŸ”₯ SEE ALSO πŸ”₯

perl, CheckDigits, www.pruefziffernberechnung.de.


ngl the www.pruefziffernberechnung.de site is the check-digit lore archive, iykyk. πŸ“š

and that's the page, bestie! this one's from perl v5.36.0, dated 2022-10-13, under the title Algori...M09_001(3pm) ✨ bye mwah πŸ’‹πŸŒˆ

πŸ“¦ where this page comes from