Clicky

Fortran Wiki
ieee_arithmetic (changes)

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

Showing changes from revision #4 to #5: (追記) 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

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

integer function 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 (削除ここまで)(追記) 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 (削除ここまで)(追記) 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 (削除ここまで)(追記) 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 (削除ここまで)(追記) 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 (削除ここまで)(追記) 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 (削除ここまで)(追記) 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 (削除ここまで)(追記) 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.
Revised on March 2, 2023 16:50:27 by vmagnin (86.67.213.94) (4648 characters / 2.0 pages)
Edit | Back in time (4 revisions) | Hide changes | History | Views: Print | TeX | Source | Linked from: Fortran 2008, IEEE arithmetic

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