zoukankan      html  css  js  c++  java
  • C++中的 Round(),floor(),ceil()

                                                                2.1             2.6              -2.1              -2.6
    floor : 不大于自变量的最大整数             2                2                  -3                  -3
    ceil   :不小于自变量的最大整数              3                3                  -2                  -2
    round:四舍五入到最邻近的整数             2                3                  -2                  -3

    round(num,num_dight) 把num精确到num_dight位数
    floor(),ceil() 需包含头文件<math.h>

    C++中没有直接的round函数 需自己建立
    double round(double r)
    {
        return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
    }
  • 相关阅读:
    Stepping Number
    Replace String
    String Permutation
    Clock Angle
    Keypad Permutation
    Replace Words
    1、奉加微 PHY6202 Get started
    Python3 修改二进制文件
    Google Fast Pair
    python 校验 BLE resolvable private address
  • 原文地址:https://www.cnblogs.com/zhuruibi/p/8972605.html
Copyright © 2011-2022 走看看