double类型向上取整 和向下取整

时间:2015-06-03 11:49:18   收藏:0   阅读:248
#include "stdafx.h"
#include <math.h>
#include <stdio.h>

int main(int argc, char* argv[])
{

    double a = 77.001;
    double b = ceil(a);

    printf("b = %.3f\n",b);

    double c = 77.999;
    double d = floor(c);
    printf("d = %.3f\n",d);
    return 0;
}

输出:
b = 78.000
d = 77.000
Press any key to continue

原文:http://blog.csdn.net/djb100316878/article/details/46342883

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!