1
0

utilities/bin

This commit is contained in:
dtb
2022-05-14 20:52:57 -04:00
parent 3334b25b77
commit 27a1dead1a
17 changed files with 324 additions and 0 deletions

14
bin/subtract Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/sh
# science speak from wikipedia
! eq $# 2 && printf "Usage: $0 [minuend] [subtrahend]\n" >/dev/stderr && exit 1
! stris int "$1" && printf "$0: $1: Not an integer\n" >/dev/stderr && exit 1
! stris int "$2" && printf "$0: $2: Not an integer\n" >/dev/stderr && exit 1
minuend=$1
subtrahend=$2
# (- a b) == (+ a (* b -1))
printf "%b\n" $(add $minuend $(multiply $subtrahend -1))
exit 0