#include <iostream>
#include <limits>
int main()
{
float x = std::numeric_limits<float>().min(); // x = 1.17549e-38
float y = 1.17549e-39f; // I created a variable that is less than min float value. How is it possible?
if(x < y)
std::cout << "x < y" << std::endl;
else if (x == y)
std::cout << "x == y" << std::endl;
else
std::cout << "y < x" << std::endl;
std::cout << x << std::endl; // x = 1.17549e-38
std::cout << y << std::endl; // y = 1.17549e-39. No errors, no warnings.
return 0;
}
When I tried to:
float y = 1.17549e-46f;
I got the warning: floating constant truncated to zero