1
0
src/bin/mod

14 lines
397 B
Plaintext
Raw Normal View History

2022-05-14 18:52:57 -06:00
#!/bin/sh
! eq $# 2 && printf "Usage: $0 [dividend] [divisor]\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
dividend=$1
divisor=$2
# (% a b) == (- a (* b (// a b)))
printf "%b\n" $(subtract $dividend $(multiply $divisor $(fdivide $dividend $divisor)))
exit 0