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
    需包含头文件<math.h>

    round可以自己写

    double round(double r)
    {
        return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
    }

    round函数C++中究竟有没有存在歧义。

    经测试math头文件中包含round函数。

    注意:四舍五入是往大数方向入

  • 相关阅读:
    Friends ZOJ
    2^x mod n = 1 HDU
    Paint the Grid Reloaded ZOJ
    Treap 模板
    bzoj进度条
    。。。
    bzoj
    。。。
    bzoj
    题解continue
  • 原文地址:https://www.cnblogs.com/Ritchie/p/5449780.html
Copyright © 2011-2022 走看看