14 lines
397 B
Plaintext
14 lines
397 B
Plaintext
|
#!/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
|