dec.h(3)
🎀 dec.h 🎀
okay so bestie, sit down, hydrate, because this is dec.h from the Library Functions Manual (section 3 — library girlies only 💅) and she is literally the queen of decimal strings.
💖 NAME 💖
dec.h — decimal strings (Десятичные строки) ✨
🌸 SYNOPSIS 🌸
#include 'bee2/defs.h'
🫶 Функции (the whole roster, no skips)
bool_t decIsValid (const char *dec)— is this even a valid decimal string, bestie?size_t decCLZ (const char *dec)— how many leading zero digits are we dealing withvoid decFromU32 (char *dec, size_t count, register u32 num)— load it up from au32numberu32 decToU32 (const char *dec)— convert it into au32numberchar decLuhnCalc (const char *dec)— compute the Luhn check digitbool_t decLuhnVerify (const char *dec)— verify the Luhn check digitchar decDammCalc (const char *dec)— compute the Damm check digitbool_t decDammVerify (const char *dec)— verify the Damm check digit
🦋 Подробное описание 🦋 (the DESCRIPTION section, and it eats)
so here's the tea ☕: management of decimal strings is implemented here — and a "decimal string" is just a word over the alphabet {'0',..,'9'} that represents numbers and memory buffers. main character energy, fr fr 👑
The first character (digit) is the most significant one — i.e. big-endian order is what we use, no debate. Wanna flip it? That's literally what strRev() is for. 💅
Both the Luhn algorithm (1954) and the Damm algorithm (2004) for computing the check digit of a decimal string are implemented. The Luhn algorithm is standardized in ISO/IEC 7812. ✨
⭐ Характеристики алгоритма Луна (Luhn algorithm characteristics) ⭐
the link is https://en.wikipedia.org/wiki/Luhn_algorithm, and she:
- detects single errors in digits;
- detects all single transpositions of adjacent digits, except
09 <-> 90; - detects all single errors in repeated digits, except
22 <-> 55,33 <-> 66and44 <-> 77.
The Damm algorithm (https://en.wikipedia.org/wiki/Damm_algorithm) detects all single errors and transpositions. she ate and left zero crumbs 💀
The length of the string whose check digit is being verified is 1 more than the length of the string whose check digit is being computed. The check digit of the string being verified is assumed to have been added on the right. That is literally exactly how the Luhn check digit is added to a credit card number (as a rule, 15 digits) and to an IMEI number (as a rule, 14 digits). 🫶
🌈 Предусловие (precondition — do NOT skip this one)
Every function except decIsValid() gets valid decimal strings and memory buffers passed into it. periodt. 🎀
🧚 Функции 🧚
size_t decCLZ (const char * dec)
The length of the run of leading zero digits in the string dec is determined. 📏
Возвращает — the length of the run.
Прим. — CLZ == Count of Leading Zeros, iykyk
Регулярность — the function is irregular (функция нерегулярна — she does not do regular, bestie 💀).
Аргументы
- dec — decimal string (десятичная строка)
char decDammCalc (const char * dec)
With the help of the Damm algorithm, the check digit of the decimal string dec is determined. 🎀
Возвращает — the check digit.
Аргументы
- dec — decimal string
bool_t decDammVerify (const char * dec)
With the help of the Damm algorithm, the check digit written at the end of the decimal string dec is verified. 🔍
Возвращает — the success flag (признак успеха).
Аргументы
- dec — decimal string
void decFromU32 (char * dec, size_t count, register u32 num)
The low-order count decimal digits of the number num are converted into the decimal string [count + 1]dec. ✨
Аргументы
- dec — decimal string
- count — the number of digits (число цифр)
- num — the number (число)
bool_t decIsValid (const char * dec)
The validity of the decimal string dec is checked. A string counts as valid if it's made up of characters from the alphabet {'0',...,'9'}. ✅
Возвращает — the validity flag (признак корректности).
Регулярность — the function is irregular (функция нерегулярна).
Аргументы
- dec — decimal string
char decLuhnCalc (const char * dec)
With the help of the Luhn algorithm, the check digit of the decimal string dec is determined. 💖
Возвращает — the check digit.
Аргументы
- dec — decimal string
bool_t decLuhnVerify (const char * dec)
With the help of the Luhn algorithm, the check digit written at the end of the decimal string dec is verified. 🔍
Возвращает — the success flag.
Аргументы
- dec — decimal string
u32 decToU32 (const char * dec)
The decimal string dec is converted into a u32 number. 🔢
Возвращает — the number you're looking for, \mod 2^32.
Предупреждения — overflow is possible 😭. To check that there's no overflow:
strLen(dec) - decCLZ(dec) < 10 || strLen(dec) - decCLZ(dec) == 10 && strCmp(dec + decCLZ(dec), "4294967295") <= 0
Аргументы
- dec — decimal string
👑 Автор 👑
Automatically generated by Doxygen for the Bee2 Library (Библиотека Bee2) from the source text. ✨
okay bestie that's the whole entire page, you ate 🫶 — this was dec.h(3) from the Bee2 Library (Библиотека Bee2), dated Вс 25 Янв 2026 00:00:00 (that's Sun 25 Jan 2026 00:00:00 for the non-Russian speakers 💅). now go validate some decimal strings, mwah 💖
📦 where this page comes from
- fedora 44: bee2-devel 2.2.0-1.fc44 · GPL-3.0-only and GPL-3.0-or-later
- fedora 44: bee2-devel 2.2.0-1.fc44 · GPL-3.0-only and GPL-3.0-or-later
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms