I don't understand why when I add 1 to a big float number I can't see a difference. I suppose it's linked to the precision ? But I cannot figure out how to solve it. Can someone explains me why this happen and how I can see if "1" was correctly added to the variable "hello" ?
#include <iostream>
#include <limits>
using namespace std;
int main()
{
float hello = 2227169280.0f;
cout<<"Hello: " << hello << endl;
printf("%f\n",hello);
hello = hello + 1.0f;
cout <<"Hello: " << hello << endl;
printf("%f\n",hello);
return 0;
}
Result:
Hello: 2.22717e+09
2227169280.000000
Hello: 2227169280
2227169280.000000 //<-- why it's not 2227169281.000000 ??
Thank you a lot.