Remove bc dependency

Co-authored-by: Jeremy Denoun <jeremy.denoun@iguanesolutions.com>
This commit is contained in:
jeremydenoun
2021-01-22 09:31:53 +01:00
committed by GitHub
parent 1c2e171655
commit 0edb837f80
6 changed files with 24 additions and 7 deletions

View File

@ -112,3 +112,20 @@ sudo_wrapper() {
crit "Not allowed to \"sudo -n $*\" "
fi
}
#
# Math functions
#
function div() {
local _d=${3:-2}
local _n=0000000000
_n=${_n:0:$_d}
if (($2 == 0)); then
echo "N.A"
return
fi
local _r=$(($1$_n / $2))
_r=${_r:0:-$_d}.${_r: -$_d}
echo $_r
}