So, I ran this code on my code blocks:
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int a;
a=pow(10,9);
cout<<a<<endl;
a=ceil(pow(10,9));
cout<<a<<endl;
a=floor(pow(10,9));
cout<<a<<endl;
return 0;
}
I got the output as:
999999999
100000000
100000000
1st output was not 10^9 due to truncation effect,which means that pow(10,9) was something like 999999999.99999.., but then how come floor of this thing is 1000000000 ??
Actually, the maximum value for
int
is 2,147,483,647, therefore there should be no overflow or truncation (it's anint
). And my output is exactly: