LoginSignup
9
8

More than 5 years have passed since last update.

[printf]bashでprintfを使う(小数点以下で四捨五入)

Last updated at Posted at 2015-11-02
read a 
printf '%.3f \n' `echo $a | bc -l `

入力された計算式(例えば-105+50*3/20 + (19^2)/7みたいな)を計算して小数点以下3桁まで四捨五入して表示したい時のスクリプト。

9
8
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8