1
0
src/bin/subtract
2022-05-14 20:52:57 -04:00

15 lines
396 B
Bash
Executable File

#!/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