歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux編程 >> SHELL編程

Linux Shell learning -- bash裡自帶的浮點計算器

Linux bash calculator 感覺用起來蠻方便,至少是偷懶比較方便,嘻嘻

How to:

1.通過命令行
#scale 表示浮點數的精確位數
[[email protected] ~]# bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
3+4
7
scale=2;3/4
.75

ctrl +d


2.通過計算文檔統一進行計算
[[email protected] ~]# vi calc.bc
[[email protected] ~]# cat calc.bc
3+4
scale=2;3/4
[[email protected] ~]# bc calc.bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
7
.75

ctrl +d


3.數制的轉換
#ibase  是指輸入的數制,obase是指輸出的數制
[[email protected] ~]# echo 'ibase=10;obase=2;11'|bc

1011


Reference:

http://www.linuxidc.com/Linux/2012-01/52386p2.htm

Copyright © Linux教程網 All Rights Reserved