Handling floating-point exceptions

By default, invalid operations such as division by zero, division by infinity, overflow, and underflow are ignored at run time. However, you can use the -ftrapping-math (-qflttrap) option or call C or operating system functions to detect these types of exceptions. If you enable floating-point traps without using the -ftrapping-math (-qflttrap) option, use the -qfloat=fenv option.

In addition, you can add suitable support code to your program to make program execution continue after an exception occurs and to modify the results of operations causing exceptions.

Because, however, floating-point computations involving constants are usually folded at compile time, the potential exceptions that would be produced at run time might not occur. To ensure that the -ftrapping-math (-qflttrap) option traps all runtime floating-point exceptions, you can use the -qfloat=nofold option to suppress all compile-time folding.



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us