17
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

bcの割り算の結果を小数にする

Posted at

bcで普通に割り算すると整数で値が返る。
少数で値を返したいときは、 -l オプションか、scale=桁数 使う

[~]$echo  "3/2" | bc
1
[~]$echo  "3/2" | bc -l
1.50000000000000000000
[~]$echo  "scale=3; 3/2" | bc
1.500
17
11
1

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
17
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?