Class FString: improve floating point exception handling
This commit is contained in:
parent
21e9e0d397
commit
97cefa927f
|
@ -1027,7 +1027,7 @@ float FString::toFloat() const
|
|||
double d;
|
||||
d = this->toDouble();
|
||||
|
||||
if ( d > FLT_MAX || d < FLT_MIN )
|
||||
if ( d > FLT_MAX || d < FLT_MIN )
|
||||
throw std::overflow_error ("overflow");
|
||||
|
||||
return float(d);
|
||||
|
|
|
@ -126,9 +126,9 @@ int main (int, char**)
|
|||
{
|
||||
std::cerr << "Invalid argument: " << ex.what() << std::endl;
|
||||
}
|
||||
catch (const std::out_of_range& ex)
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
std::cerr << "Out of range: " << ex.what() << std::endl;
|
||||
std::cerr << "Arithmetic error: " << ex.what() << std::endl;
|
||||
}
|
||||
|
||||
try
|
||||
|
|
Loading…
Reference in New Issue