Source
- using an arithmetic expression (
$(( $a / $b ))
) only gives an integer result - use
bc
for proper floating point math
a=100
b=42
echo $a / $b = $(bc <<<"scale=2; $a / $b")
Source
$(( $a / $b ))
) only gives an integer resultbc
for proper floating point matha=100
b=42
echo $a / $b = $(bc <<<"scale=2; $a / $b")