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

14 lines
397 B
Bash
Executable File

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