search
LoginSignup
8

More than 5 years have passed since last update.

posted at

updated at

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

read a 
printf '%.3f \n' `echo $a | bc -l `

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

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
What you can do with signing up
8