红联Linux门户
Linux帮助

Linux Shell learning-bash里自带的浮点计算器

发布时间:2014-11-25 09:51:26来源:linux网站作者:qzier_go

Linux bash calculator 感觉用起来蛮方便,至少是偷懒比较方便,嘻嘻

How to:


1.通过命令行
#scale 表示浮点数的精确位数
[root@www ~]# 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.通过计算文档统一进行计算
[root@www ~]# vi calc.bc
[root@www ~]# cat calc.bc
3+4
scale=2;3/4
[root@www ~]# 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是指输出的数制
[root@www ~]# echo 'ibase=10;obase=2;11'|bc

1011