Clicky

Fortran Wiki
ieee_arithmetic (Rev #4, changes)

Skip the Navigation Links | Home Page | All Pages | Recently Revised | Authors | Feeds | Export |

Showing changes from revision #3 to #4: (追記) Added (追記ここまで) | (削除) Removed (削除ここまで) | (削除) Chan (削除ここまで)(追記) ged (追記ここまで)

The module ieee_arithmetic is an intrinsic module defined in the technical report ISO/IEC TR 15580:1998(E) which provides IEEE arithmetic facilities.

IEEE Datatype Selection

(削除) selected\_real\_kind (削除ここまで)(追記) ieee_selected\_real\_kind (追記ここまで)

integer function (削除) selected_real_kind (削除ここまで)(追記) ieee_selected_real_kind (追記ここまで)(p,r)
 integer(kind1), optional :: p
 integer(kind2), optional :: r

This function behaves like the selected_real_kind intrinsic, but only returns numbers of of IEEE kinds of reals.

General Inquiry Functions

ieee\_support\_datatype

logical function ieee_support_datatype(x)
 real(kind), optional :: x

Returns .true. if IEEE arithmetic is supported for the same kind of real as x (or for all real kinds if x is absent).

ieee\_support\_denormal

logical function ieee_support_denormal(x)
 real(kind), optional :: X

Returns .true. if IEEE denormal values are supported for the same kind of real as x (or for all real kinds if x is absent).

ieee\_support\_divide

logical function ieee_support_divide(x)
 real(kind), optional :: x

Returns .true. if division up to IEEE-specified accuracy is supported for the same kind of real as x (or for all real kinds if x is absent).

ieee\_support\_inf

logical function ieee_support_inf(x)
 real(kind), optional :: x

Returns .true. if IEEE infinite values are supported for the same kind of real as x (or for all real kinds if x is absent).

ieee\_support\_nan

logical function ieee_support_nan(x)
 real(kind), optional :: x

Returns .true. if IEEE NaN (Not-a-Number) values are supported for the same kind of real as x (or for all real kinds if x is absent).

ieee\_support\_sqrt

logical function ieee_support_sqrt(x)
 real(kind), optional :: x

Returns .true. if sqrt follows the IEEE standard for the same kind of real as x (or for all real kinds if x is absent).

ieee\_support\_standard

logical function ieee_support_standard(x)
 real(kind), optional :: x

Returns .true. if all the IEEE facilities are supported for the same kind of real as x (or for all real kinds if x is absent).

Rounding Modes

Number Classification

The module also contains the following elemental functions for reals x and y for which ieee_support_datatype is true:

  • ieee_class(x)–ieee class.
  • ieee_value(x,class)–generate a sample IEEE value of the specified class.
  • ieee_is_finite(x)–determine if a value is finite.
  • ieee_is_nan(x)–determine if a value is IEEE NaN.
  • ieee_is_negative(x)–determine if a value is negative.
  • ieee_is_normal(x)–determine if a value is "normal," neither an Inf, NaN, nor denormalized.
  • ieee_unordered(x,y)–IEEE unordered function. True if either x or y is NaN and false otherwise.

Values of type ieee_class_type indicate the IEEE class of a number which can be one of the following

type(ieee_class_type), parameter :: ieee_negative_denormal
type(ieee_class_type), parameter :: ieee_negative_inf
type(ieee_class_type), parameter :: ieee_negative_normal
type(ieee_class_type), parameter :: ieee_negative_zero
type(ieee_class_type), parameter :: ieee_positive_denormal
type(ieee_class_type), parameter :: ieee_positive_inf
type(ieee_class_type), parameter :: ieee_positive_normal
type(ieee_class_type), parameter :: ieee_positive_zero
type(ieee_class_type), parameter :: ieee_quiet_nan
type(ieee_class_type), parameter :: ieee_signaling_nan 

The module ieee_arithmetic also defines the == and /= operators for the ieee_class_type. These may be used to test the return value of the ieee_class function. For example:

if (ieee_class(x) == ieee_quiet_nan) then
 ! ...
end if

Arithmetic operations

  • ieee_copy_sign(x,y)–IEEE copysign function.
  • ieee_logb(x)–unbiased exponent in the IEEE floating point format.
  • ieee_next_after(x,y)–returns the next representable neighbor of x in the direction toward y.
  • ieee_rem(x,y)–the IEEE rem function, that is x - y*n, where n is the integer nearest to the exact value x/y.
  • ieee_rint(x)–round to an integer value according to the current rounding mode.
  • ieee_scalb(x,i)–Returns x*2i.
Revision from May 4, 2015 09:22:32 by Anonymous Coward
Forward in time (to current) | Back in time (3 more) | See current | Hide changes | History | Rollback | View: Source | Linked from: Fortran 2008, IEEE arithmetic

AltStyle によって変換されたページ (->オリジナル) /