Converting a value of type long double
to a value of type float
is well-defined and meaningful. If the result is too large to store in a float
, the result is a floating-point exception, which by default has no effect; the stored value is +inf
or -inf
.
A floating-point exception is not a C++ exception; it's specific to floating point, and will not be seen when your code runs, unless you've gone out of your way to install a floating-point trap handler. Maybe your IDE installs a trap handler; if so, you'll have to consult the documentation to figure out how to disable this "feature".