<分区>
如何在 bash 中添加两位小数? 比如这个
LAT=37.748944
LNG=-122.4175548
D=0.01
somecommand --position "$(( LAT + D )), $(( LNG + D ))"
失败
37.748944: syntax error: invalid arithmetic operator (error token is ".748944")
<分区>
如何在 bash 中添加两位小数? 比如这个
LAT=37.748944
LNG=-122.4175548
D=0.01
somecommand --position "$(( LAT + D )), $(( LNG + D ))"
失败
37.748944: syntax error: invalid arithmetic operator (error token is ".748944")
最佳答案
您可以使用bc
,它应该可以用于十进制计算:
LAT=37.748944
LNG=-122.4175548
D=0.01
somecommand --position "$(echo "$LAT + $D" | bc), $(echo "$LNG + $D" | bc)"
关于bash - 在bash脚本中添加两位小数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38751037/