C form onvalidating


Errors during floating-point operations are often neglected by programmers who instead focus on validating operands before an operation.

Only implementations that use IEC 60559 (formerly IEEE-754) floating-point arithmetic are required to support all five exceptions defined by C (see the C Standard, subclause 7.6.2 [ISO/IEC 9811]).

Nevertheless, these functions are the most portable solution for handling floating-point exceptions.

A less portable but potentially more secure solution is to use the capabilities provided by the underlying implementation.

If this approach is taken, the caveats of that system must be well understood.

The following table provides a starting point for some common operating systems: In this noncompliant code example, floating-point operations are performed without checking for errors.

Note that range checking has been intentionally omitted because the intent is to detect errors following the floating-point operation.

You must have an account to comment. Please register or login here!