我一直在尝试天花板功能,并得到了一些奇怪的结果。如果我对乘以百的十进制数执行 ceil 运算,我会得到一定的结果。但是,如果我直接对该乘法的结果执行 ceil ,我会得到完全不同的输出。另一个转折是这些不同的结果只发生在某些数字上。任何帮助,将不胜感激。
#include <stdio.h>
#include <cmath>
int main ()
{
cout << "The ceiling of " << 411 << " is " << ceil(411) << endl;
cout << "The ceiling of 4.11*100 is " << ceil(4.11*100) << endl;
cout << "The ceiling of " << 121 << " is " << ceil(121) << endl;
cout << "The ceiling of 1.21*100 is " << ceil(1.21*100) << endl;;
}
OUTPUT:
The ceiling of 411 is 411
The ceiling of 4.11*100 is 412
The ceiling of 121 is 121
The ceiling of 1.21*100 is 121