how to calculate float numbers: with bash
example
DRIVER_MEMORY=$(( 5 * 0.6 * 0.9 ))
-bash: 5 * 0.6 * 0.9 : syntax error: invalid arithmetic operator (error token is ".6 * 0.9 ")
remark - results must be integer number - so we can round the number to down
bash
,awk
, orbc
? – jesse_b Feb 12 '18 at 13:40bash
doesn't do float. The syntax error really means "error: input not an integer".DRIVER_MEMORY=$((5*6*9/100))
orDRIVER_MEMORY=$(((5*6*9+50)/100))
does this calculation (depending on your desired rounding mode) if you want to avoid forking out another process – Fox Feb 12 '18 at 14:09