The following code snippet
void main()
{
float a = 68440675640679078541805800652800.0f;
float b = a*a;
cout << b << endl;
}
produces a floating-point overflow runtime error in MSVC 2017. I do not want to check if the float a is small enough for a muliplication.
How is it possible to tell the C++ compiler to build a programm which ignores floating-point overflow and underflow errors? Researching for an answer I came across the function _controlfp_s at
https://learn.microsoft.com/de-de/cpp/c-runtime-library/reference/controlfp-s?view=vs-2019
But I did not manage to get it to work.
float b = a*a;will produce overflow. What value do you want to be stored intob(at compile time) in this case?