I know there is a lot of similar topics, but usually problem is different rounding, like 5 instead of 4, and the proper value is a double value because it have bigger precision. During making some stuff I met below problem. I wrote new, short program to present it. Why is this happening?
#include <iostream>
using namespace std;
int main()
{
double lbs1 = 285.7;
float lbs2 = 285.7f;
double pds_left1 = lbs1 - int (lbs1);
double pds_left2 = lbs2 - int (lbs2);
cout << "1: " << pds_left1 << endl;
cout << "2: " << pds_left2 << endl;
return 0;
}
The result is:
1: 0.7
2: 0.700012