24.05.2014 Views

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

v<br />

The fltint suboption speeds up float-to-integer conversions by reducing error<br />

checking <strong>for</strong> overflows. You should make sure that any floats that are converted<br />

to integers are not outside the range of the corresponding integer types.<br />

In cases where speed is so important that you can make an in<strong>for</strong>med decision to<br />

sacrifice correctness at boundary conditions, you can replace hssngl and fltint with<br />

the hsflt suboption; it does the same thing as fltint and suppresses rounding<br />

operations.<br />

In suppressing rounding operations, hsflt works like hssngl, but it also suppresses<br />

rounding operations when double-precision values are assigned to single-precision<br />

memory locations. Single-precision overflow is not detected in such assignments,<br />

and the assigned value is not correctly rounded according to the current rounding<br />

mode.<br />

Attention: When you use the hsflt suboption, observe these restrictions, or your<br />

program may produce incorrect results without warning:<br />

v Your program must never convert overly large floats to integer.<br />

v Your program must never compute NaNs, or values outside the range of single<br />

precision.<br />

v Your program must not depend on results to be correctly rounded to single<br />

precision: <strong>for</strong> example, by comparing two single-precision values <strong>for</strong> equality.<br />

There<strong>for</strong>e, we recommend that you use this suboption only with extreme caution.<br />

It is <strong>for</strong> use by knowledgeable programmers in specific applications, such as<br />

graphics programs, where the computational characteristics are known. If you are<br />

at all unsure whether a program is suitable or if the program produces unexpected<br />

results when you use this suboption, use hssngl instead.<br />

Related In<strong>for</strong>mation: “Technical Details of the -qfloat=hsflt Option” on page 412<br />

provides additional technical in<strong>for</strong>mation about this<br />

suboption.<br />

Detecting and Trapping Floating-Point Exceptions<br />

As stated earlier, the IEEE standard <strong>for</strong> floating-point arithmetic defines a number<br />

of exception (or error) conditions that might require special care to avoid or<br />

recover from. The following sections are intended to help you make your programs<br />

work safely in the presence of such exception conditions while sacrificing the<br />

minimum amount of per<strong>for</strong>mance.<br />

The floating-point hardware always detects a number of floating-point exception<br />

conditions (which the IEEE standard rigorously defines): overflow, underflow,<br />

zerodivide, invalid, and inexact.<br />

By default, the only action that occurs is that a status flag is set. The program<br />

continues without a problem (although the results from that point on may not be<br />

what you expect). If you want to know when an exception occurs, you can arrange<br />

<strong>for</strong> one or more of these exception conditions to generate a signal.<br />

The signal causes a branch to a handler routine. The handler receives in<strong>for</strong>mation<br />

about the type of signal and the state of the program when the signal occurred. It<br />

can produce a core dump, display a listing showing where the exception occurred,<br />

modify the results of the calculation, or carry out some other processing that you<br />

specify.<br />

296 <strong>XL</strong> <strong>Fortran</strong> <strong>Enterprise</strong> <strong>Edition</strong> <strong>for</strong> <strong>AIX</strong> : User’s <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!