Skip to content

Instantly share code, notes, and snippets.

@kaskavalci
Created September 26, 2015 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaskavalci/303cd56b0a9bda67decb to your computer and use it in GitHub Desktop.
Save kaskavalci/303cd56b0a9bda67decb to your computer and use it in GitHub Desktop.
void smallerF()
{
cout << "MIN FLOAT test" << endl;
errno = 0;
stringstream ss;
ss << "1.17549430e-39";
cout << "Min possible :\t" << FLT_MIN << endl;
cout << "str: \t\t" << ss.str() << endl;
float converted = strtof(ss.str().c_str(), NULL);
cout << "Error: \t\t" << (errno == ERANGE ? "Range error" : "No error") << endl;
cout << "Converted: \t" << converted << endl;
cout << "Normal :\t" << (isnormal(converted) ? "True" : "False") << endl;
cout << "Comparison: \t" << (converted < FLT_MIN ? "smaller" : "greater or equal") << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment