Linux Shell中浮点运算方式

唐门问心 2011-07-25

用bc或awk

$a=3.4 b=345.3

echo "scale=4;$a*$b/2"|bc

587.0100

$echo $a*$b/2|bc -l

587.01000000000000000000

$awk 'BEGIN{printf '$a'*'$b'/2}'

587.01

相关推荐