Floating point arithmetic
Bash does not support floating-point operations. If you need to perform floating-point operations, you can use bc, awk.
method one:
echo "数字1运算符数字2" | bc 注意空格及符号
Method Two:
echo " 数字1运算符数字2 ">文件 注意空格及符号
bc 文件
Method 1 and Method 2 have the same limitation, that is, multiplication and division cannot be accurate calculations. If you want accurate calculations, you can use method 3.
Method three:
echo "scale=有效数字;数字1算法数字2"|bc 注意空格及符号
Method four:
echo $(awk BEGIN'{print 数字1运算符数字2}') 注意空格及符号
You can see that awk can't do accurate calculations either