modulus.c

来自「c语言库函数!里面包含了所以c语言中的系统函数的实现及其详细说明和代码!请大家及」· C语言 代码 · 共 38 行

C
38
字号
/* +++Date last modified: 05-Jul-1997 */

/****************************************************************************
* @(#)MODULUS.c
* @(#)- Basic routines for creating and checking modulus values
*
*
*****************************************************************************
* CONTENTS:
*
*   modulus10() ;        Returns the modulus 10 check digit.
*   modulus11() ;        Returns the modulus 11 check digit
*   check_modulus10() ;  Checks if the check digit in string is correct
*   check_modulus11() ;  Checks if the check digit in string is correct
*
*****************************************************************************
* DESCRIPTION:
*
* Calculations of modulus 10 check digits:
*
*   Multiply units position an every       Base 6 1 2 4 8
*   alternate position i basic code             6   2   8
*   number by 2, starting from righthand
*   digit                                                 = 1256
*
*   Bring down digits that were not               1   4
*   multiplied by 2
*
*   Cross add these digits to digits in
*   first product                             1+2+5+6+1+4 = 19
*
*   Enter next higher number with a ending
*   zero. If the number already ends with
*   zero keep it.                                           20
*
*   Subtract the cross add sum with next
*   higher and you've got the check digit         20 - 19 = 1
*                                                           

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?