从校验码计算应得余数 -> 减去前16位已得余数, 得余数偏差, 偏差为负则 加 11, 得非负余偏差后, 判断奇偶, 非负余偏差是奇数就加11, -> 最后除以 2(第17位的系数) 商就是第17位的数字- @echo off & setlocal enableDelayedExpansion
- for %%i in (
- 1509231988042396#9
- 3700001989091894#0
- 4313021981042877#1
- 5301021920050801#X
- 6110251990062874#0
- ) do (
- set "d=%%i"
- set "c=!d:~-1!"
- set /a "c=!c:x=10!, t= c - 2>>31, r=t&(c^^1)|~t&(12-c), dr= r - ( (!d:~0,1!+!d:~10,1!)*7+(!d:~1,1!+!d:~11,1!)*9+(!d:~2,1!+!d:~12,1!)*10+(!d:~3,1!+!d:~13,1!)*5+(!d:~4,1!+!d:~14,1!)*8+(!d:~5,1!+!d:~15,1!)*4+!d:~6,1!*2+!d:~7,1!+!d:~8,1!*6+!d:~9,1!*3 ) %% 11, u=dr+(dr>>31&11), v=(u+(u&1)*11)/2"
- echo;!d:~0,-2!!v!!d:~-1!
- )
- pause
复制代码
|