学习啦>学习电脑>操作系统>Linux教程>

linux计算命令

时间: 佳洲1085 分享

  EOF

  }

  将以上代码粘贴到终端。

  [root@web ~]# # usage: calc_sum

  [root@web ~]# # 计算两个数的和

  [root@web ~]# calc_sum()

  > {

  > bc -q <

  > class="main">

linux计算命令

时间: 佳洲1085 分享

  > EOF

  > }

学习啦在线学习网   [root@web ~]#

  [root@web ~]#

  [root@web ~]# calc_sum 123 321

  444

  [root@web ~]# calc_fee 1000

  50.00

学习啦在线学习网   [root@web ~]#

学习啦在线学习网   示例七 使用数学库

  有文章称可以计算100位的圆周率pi值。

学习啦在线学习网   [root@web ~]# echo "scale=100; a(1)*4" | bc

学习啦在线学习网   Runtime error (func=(main), adr=11): Function a not defined.

  [root@web ~]# echo "scale=100; a(1)*4" | bc -l

  3.141592653589793238462643383279502884197169399375105820974944592307\

  8164062862089986280348253421170676

  [root@web ~]#

3599454