zoukankan      html  css  js  c++  java
  • bc命令

    bc 命令:
         bc 命令是用于命令行计算器。 它类似基本的计算器。 使用这个计算器可以做基本的数学运算。


    [tough@localhost expr]$ echo 8*3|bc
    24
    
    [tough@localhost expr]$ echo '8+2'|bc
    10
    
    [tough@localhost expr]$ echo "8 -2"|bc
    6

    把要计算工的内容放入文件中:

    [tough@localhost expr]$ echo "4+5" > cal.txt
    
    [tough@localhost expr]$ bc cal.txt
    bc 1.06.95
    Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
    This is free software with ABSOLUTELY NO WARRANTY.
    For details type `warranty'.
    9
    进入bc模式:
    [tough@localhost expr]$ bc
    bc 1.06.95
    Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
    This is free software with ABSOLUTELY NO WARRANTY.
    For details type `warranty'.
    
    6+2
    8
    
    6 +2
    8
    
    6-2
    4
    
    6*2
    12
    
    6/2
    3
    
    
    2^4
    16
    
    5%3
    2
    
    5/3
    1
    
    
    #设置精度 scale
    =2 5/3 1.66 5/2 2.50 (5^3 - 25)/4 + 1 26.00 quit
    s (x)  The sine of x, x is in radians.    正玄函数
    
    c (x)  The cosine of x, x is in radians.  余玄函数
    
    a (x)  The arctangent of x, arctangent returns radians. 反正切函数
    
    l (x)  The natural logarithm of x.  log函数(以2为底)
    
    e (x)  The exponential function of raising e to the value x.  e的指数函数
    
    j (n,x)
           The bessel function of integer order n of x.   贝塞尔函数
    
    
    echo "scale=100; a(1)*4" | bc -l  (计算圆周率)    
              
  • 相关阅读:
    scrollView(3)-相册浏览简单的缩放
    ScrollView(2)轮播图-点击跳转
    定制单元格-cell
    模态视图present
    将博客搬至CSDN
    VBS进行http请求及JSON数据的读取和生成
    igraph安装(R/Python)
    teiid入门
    漫谈设计模式
    MapReduce实例-基于内容的推荐(一)
  • 原文地址:https://www.cnblogs.com/toughhou/p/3898413.html
Copyright © 2011-2022 走看看