私は天井関数を試していて、いくつかの奇妙な結果を得ています。10進数に100を掛けてceil演算を実行すると、特定の結果が得られます。ただし、その乗算の結果に対して直接ceilを実行すると、まったく異なる出力が得られます。もう1つのひねりは、これらの異なる結果が特定の数に対してのみ発生することです。どんな助けでもいただければ幸いです。
#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