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

#include "stdafx.h"
#include 
#include 

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

你可能感兴趣的:(c/c++)