php常用数学计算

  1. 作者QQ:67065435 QQ群:821635552

  2. 本站内容全部为作者原创,转载请注明出处!

  3. 加减乘除余

    <?php
    $a = 9;
    $b = 3;
    $c = $a + $b;
    $d = $a - $b;
    $e = $a * $b;
    $f = $a / $b;
    $g = $a % $b;
    
  4. 指数(幂)运算

    <?php
    # 求a的b次方
    $a = 9;
    $b = 3;
    $c = pow($a, $b);
    
    # 求a的b次方根
    $a = 9;
    $b = 2;
    $c = pow($a, 1/$b);
    
  5. 对数运算

    <?php
    # 求log以a为底b的对数(a的多少次幂等于b)
    $a = 9;
    $b = 3;
    $c = log($b,$a);
    
  6. php打印π前53位小数

    <?php
    # %.53f 打印总位数不限、小数部分53位的小数
    echo sprintf('%.53f', pi());
    
  7. php取整

    ceil()   进一取整
    floor()  舍去取整
    intval() 转整型
    round()  四舍五入
    
Copyright © 豆包嘿嘿~ 2012-∞ 冀ICP备17033181号 all right reserved,powered by Gitbook修订: 2020-08-19 14:05:41

results matching ""

    No results matching ""