Algori...M10_002(3pm)
π CheckDigits::M10_002 β the Algorithm::CheckDigits family's CINS / SIREN / SIRET girlie β¨
okay so bestie, this is the manual page for Algori...M10_002(3pm) β that's the User Contributed Perl Documentation one, from the Algorithm::CheckDigits crew. She's a check-digit calculator. Specifically she does CINS (that's the US one), SIREN and SIRET (those two are French π«π·). Numbers girl math, but make it correct. π
πΈ NAME πΈ
CheckDigits::M10_002 β she computes check digits for CINS (US), SIREN (FR) and SIRET (FR). No cap.
π¦ SYNOPSIS π¦
the whole vibe, verbatim, because I would never mess with your code:
use Algorithm::CheckDigits;
$siret = CheckDigits('siret');
if ($siret->is_valid('73282932000074')) {
# do something
}
$cn = $siret->complete('7328293200007');
# $cn = '73282932000074'
$cd = $siret->checkdigit('73282932000074');
# $cd = '4'
$bn = $siret->basenumber('73282932000074');
# $bn = '7328293200007'
like, pull in Algorithm::CheckDigits, grab yourself a siret object, and she justβ¦ does the rest. main character energy fr fr. π
β¨ DESCRIPTION β¨
π ALGORITHM π
here's the recipe, step by step, and I'm keeping it exactly how she wrote it:
- Beginning right all numbers are weighted alternatively 1 and 2.
- The total of the digits of all products is computed.
- The sum of step 3 ist taken modulo 10.
- The check digit is the difference between 10 and the number from step 3 taken modulo 10.
not me noticing she says "ist" in step 3 π that's the original wording, I'm just the messenger, I promise.
the way that works out: you go from the right side of the number, alternating weights of 1 and 2 πͺ, then you add up all the digits of the products (yes, digits of the products, not the products themselves β this is the part everyone gets wrong, iykyk), mod 10 it, and the check digit is whatever gets you from that up to 10, mod 10 again. periodt. π
π METHODS π
is_valid($number)
returns true only if $number is made up of just numbers and the last digit is a valid check digit according to the algorithm up there. βοΈ
returns false otherwise.
complete($number)
the check digit for $number gets computed and concatenated onto the end of $number.
returns the complete number with its check digit β or '' (empty string, sad) if $number doesn't consist solely of digits and spaces. π«Ά
basenumber($number)
gives you back the basenumber of $number, but only if $number has a valid check digit.
returns '' otherwise. π
checkdigit($number)
gives you back the checkdigit of $number, again only if $number has a valid check digit.
returns '' otherwise. β
π EXPORT π
None by default. (she's lowkey, she doesn't just dump stuff into your namespace uninvited π)
π AUTHOR π
Mathias Weidner, "<mamawe@cpan.org>" β iconic, we stan. π
π₯ SEE ALSO π₯
perlβ hi momCheckDigitswww.pruefziffernberechnung.de.β note the trailing dot, that's exactly how she wrote it, do not @ mewww.dsi.cnrs.fr/bureau_qualite/admindonnees/documents/siren.pdf
that's the whole page bestie, go forth and validate your SIRETs π¦β¨
cute sign-off time: this wasperl v5.36.0, dated2022-10-13, and the page itself isAlgori...M10_002(3pm). drink water, check your digits, mwah π
π¦ where this page comes from
- ubuntu noble: libalgorithm-checkdigits-perl 1.3.6-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libalgorithm-checkdigits-perl 1.3.6-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libalgorithm-checkdigits-perl 1.3.6-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms