summaryrefslogtreecommitdiff
path: root/ean13
diff options
context:
space:
mode:
authorDavid Wührer <def@gmx.at>2024-05-18 21:04:34 +0200
committerDavid Wührer <def@gmx.at>2024-05-18 21:04:34 +0200
commit77cfffee6177fb0421fa0fce15d6a1875bde4816 (patch)
tree251428cdd482ea50cfb019dbd3c3bafd79d2fd14 /ean13
parent75b23ce1ff0daab363725a2a5755ea80bbeaa68e (diff)
manuals, sum-down, radix
Diffstat (limited to 'ean13')
-rwxr-xr-xean1322
1 files changed, 0 insertions, 22 deletions
diff --git a/ean13 b/ean13
deleted file mode 100755
index 6fd125a..0000000
--- a/ean13
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/bash
-while [[ $1 ]]
-do
-[[ ${#1} -eq 13 ]] || [[ ${#1} -eq 12 ]] || {
- printf >&2 'length is %d, should be 13\n' ${#1}
- exit 1
-}
-declare -i checksum=0
-declare -i factor=1
-for i in {0..11}
-do
- v=${1:i:1}
- checksum=$((checksum+factor*v))
- factor=$((factor^2))
-#printf >&2 'v: %s : cs=%d f=%d\n' "$v" $checksum $factor
-done
-if [[ ${#1} -eq 12 ]]
-then echo "$1"$((10-checksum%10))
-else [[ $((10-checksum%10)) -eq ${1:12} ]] || exit
-fi
-shift
-done