009#任意精度的浮点数计算器

使用一个包装器(wrapper),让bc用起来更加顺手。

#!/usr/bin/env bash

# 设置指定/默认精度
if [ "$1" = "-p" ]; then
  precision=$2
  shift 2
else
  # 默认精度
  precision=2
fi

bc -q << EOF
  scale=$precision
  $*
  quit
EOF
exit 0
View Code

 

 

posted @ 2020-05-28 09:46  bigtree2pingping  阅读(258)  评论(0编辑  收藏  举报