bash计算浮点数

阅读 184

2022-10-14


echo "2 / 3" | bc

.66666666666666666666

如果想要前导零

echo "2 / 3" | bc -l | xargs printf "%f"

这里还有一堆解决方案:​​https://stackoverflow.com/questions/8402181/how-do-i-get-bc1-to-print-the-leading-zero​​


bash做运算是真的烦。有点想转python了


精彩评论(0)

0 0 举报