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.

$ cat fp_values.f<br />

real plus_inf, minus_inf, plus_nanq, minus_nanq, nans<br />

real large<br />

data plus_inf /z’7f800000’/<br />

data minus_inf /z’ff800000’/<br />

data plus_nanq /z’7fc00000’/<br />

data minus_nanq /z’ffc00000’/<br />

data nans /z’7f800001’/<br />

print *, ’Special values:’, plus_inf, minus_inf, plus_nanq, minus_nanq, nans<br />

! They can also occur as the result of operations.<br />

large = 10.0 ** 200<br />

print *, ’Number too big <strong>for</strong> a REAL:’, large * large<br />

print *, ’Number divided by zero:’, (-large) / 0.0<br />

print *, ’Nonsensical results:’, plus_inf - plus_inf, sqrt(-large)<br />

! To find if something is a NaN, compare it to itself.<br />

print *, ’Does a quiet NaN equal itself:’, plus_nanq .eq. plus_nanq<br />

print *, ’Does a signaling NaN equal itself:’, nans .eq. nans<br />

! Only <strong>for</strong> a NaN is this comparison false.<br />

end<br />

$ xlf95 -o fp_values fp_values.f<br />

** _main === End of Compilation 1 ===<br />

1501-510 Compilation successful <strong>for</strong> file fp_values.f.<br />

$ fp_values<br />

Special values: INF -INF NaNQ -NaNQ NaNS<br />

Number too big <strong>for</strong> a REAL: INF<br />

Number divided by zero: -INF<br />

Nonsensical results: NaNQ NaNQ<br />

Does a quiet NaN equal itself: F<br />

Does a signaling NaN equal itself: F<br />

Exception-Handling Model<br />

The IEEE standard defines several exception conditions that can occur:<br />

OVERFLOW<br />

The exponent of a value is too large to be represented.<br />

UNDERFLOW<br />

A nonzero value is so small that it cannot be represented without an<br />

extraordinary loss of accuracy. The value can be represented only as zero<br />

or a denormal number.<br />

ZERODIVIDE<br />

A finite nonzero value is divided by zero.<br />

INVALID<br />

Operations are per<strong>for</strong>med on values <strong>for</strong> which the results are not defined.<br />

These include:<br />

v Operations on signaling NaN values<br />

v infinity - infinity<br />

v 0.0 * infinity<br />

v 0.0 / 0.0<br />

v mod(x,y) or ieee_rem(x,y) (or other remainder functions) when x is<br />

infinite or y is zero<br />

v<br />

v<br />

The square root of a negative number<br />

Conversion of a floating point number to an integer when the converted<br />

value cannot be represented faithfully<br />

<strong>XL</strong> <strong>Fortran</strong> Floating-Point Processing 289

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

Saved successfully!

Ooh no, something went wrong!