現在の数値モデルの制御と照会#

指数#

名前#

exponent(3) - [MODEL_COMPONENTS] 浮動小数点数の指数

概要#

    result = exponent(x)
     elemental integer function exponent(x)

      real(kind=**),intent(in) :: x

特性#

  • x は、任意の有効な種類の実数型です。

  • 結果は、デフォルトの整数型です。

説明#

exponent(3) は、指数がデフォルトの整数の範囲内にある場合、x の指数部の値を返します。

オプション#

  • x

    指数を照会する値

結果#

exponent(3) は、x の指数部の値を返します。

x がゼロの場合、返される値はゼロです。

x が IEEE 無限大または NaN の場合、結果は HUGE(0) の値になります。

#

サンプルプログラム

program demo_exponent
implicit none
real :: x = 1.0
integer :: i
   i = exponent(x)
   print *, i
   print *, exponent(0.0)
   print *, exponent([10.0,100.0,1000.0,-10000.0])
   print *, 2**[10.0,100.0,1000.0,-10000.0]
   print *, exponent(huge(0.0))
   print *, exponent(tiny(0.0))
end program demo_exponent

結果

 >            4           7          10          14
 >          128
 >         -125

標準#

Fortran 95

関連項目#

digits(3)epsilon(3)fraction(3)huge(3)maxexponent(3)minexponent(3)nearest(3)precision(3)radix(3)range(3)rrspacing(3)scale(3)set_exponent(3)spacing(3)tiny(3)

fortran-lang 固有関数の説明

小数部#

名前#

fraction(3) - [MODEL_COMPONENTS] モデル表現の小数部

概要#

    result = fraction(x)
     elemental real(kind=KIND) function fraction(x)

      real(kind=KIND),intent(in) :: fraction

特性#

  • x実数型です。

  • 結果は、引数と同じ特性を持ちます。

説明#

fraction(3) は、x のモデル表現の小数部を返します。

オプション#

  • x

    調査する値

結果#

x のモデル表現の小数部が返されます。これは x * radix(x)**(-exponent(x)) です。

x の値がゼロの場合、結果はゼロです。

x が IEEE NaN の場合、結果は NaN です。

x が IEEE 無限大の場合、結果は IEEE NaN です。

#

サンプルプログラム

program demo_fraction
implicit none
real :: x
   x = 178.1387e-4
   print *, fraction(x), x * radix(x)**(-exponent(x))
end program demo_fraction

結果

     0.5700439      0.5700439

標準#

Fortran 95

関連項目#

digits(3)epsilon(3)exponent(3)huge(3)maxexponent(3)minexponent(3)nearest(3)precision(3)radix(3)range(3)rrspacing(3)scale(3)set_exponent(3)spacing(3)tiny(3)

fortran-lang 固有関数の説明

最も近い数#

名前#

nearest(3) - [MODEL_COMPONENTS] 最も近い表現可能な数

概要#

    result = nearest(x, s)
     elemental real(kind=KIND) function nearest(x,s)

      real(kind=KIND),intent(in) :: x
      real(kind=**),intent(in) :: s

特性#

  • x は、任意の種類の実数値です。

  • s は、任意の種類の実数値です。

  • 戻り値は、x と同じ型および種類です。

  • **と指定された種類は、その型でサポートされている任意の種類です。

説明#

nearest(3) は、s の符号によって示される方向で、x に最も近いプロセッサで表現可能な数を返します。

オプション#

  • x

    最も近い表現可能な値を見つける値

  • s

    x から表現可能な値への検索方向を決定するために使用される符号を持つゼロ以外の値。

    s が正の場合、nearestx より大きく、最も近いプロセッサで表現可能な数を返します。

    s が負の場合、nearestx より小さく、最も近いプロセッサで表現可能な数を返します。

結果#

戻り値はxと同じ型です。sが正の場合、nearestxより大きく最も近いプロセッサで表現可能な数を返します。sが負の場合、nearestxより小さく最も近いプロセッサで表現可能な数を返します。

#

サンプルプログラム

program demo_nearest
implicit none

   real :: x, y
   x = nearest(42.0, 1.0)
   y = nearest(42.0, -1.0)
   write (*,"(3(g20.15))") x, y, x - y

!  write (*,"(3(g20.15))") &
!   nearest(tiny(0.0),1.0), &
!   nearest(tiny(0.0),-1.0), &
!   nearest(tiny(0.0),1.0) -nearest(tiny(0.0),-1.0)

!  write (*,"(3(g20.15))") &
!   nearest(huge(0.0),1.0), &
!   nearest(huge(0.0),-1.0), &
!   nearest(huge(0.0),1.0)- nearest(huge(0.0),-1.0)

end program demo_nearest

結果

   42.0000038146973    41.9999961853027    .762939453125000E-05

標準#

Fortran 95

関連項目#

digits(3)epsilon(3)exponent(3)fraction(3)huge(3)maxexponent(3)minexponent(3)precision(3)radix(3)range(3)rrspacing(3)scale(3)set_exponent(3)spacing(3)tiny(3)

fortran-lang 固有関数の説明

rrspacing#

名前#

rrspacing(3) - [MODEL_COMPONENTS] 数値型の相対間隔の逆数

概要#

    result = rrspacing(x)
     elemental real(kind=KIND) function rrspacing(x)

      real(kind=KIND),intent(in) :: x

特性#

  • x は任意の種類の実数型です。

  • 戻り値は、x と同じ型および種類です。

説明#

rrspacing(3) は、x の近傍にあるモデル数値の相対間隔の逆数を返します。

オプション#

  • x

    実数型である必要があります。

結果#

戻り値は、x と同じ型および種類です。返される値は、abs(fraction(x)) * float(radix(x))**digits(x) と等しくなります。

標準#

Fortran 95

参照#

digits(3)epsilon(3)exponent(3)fraction(3)huge(3)maxexponent(3)minexponent(3)nearest(3)precision(3)radix(3)range(3)scale(3)set_exponent(3)spacing(3)tiny(3)

fortran-lang 固有関数の説明

scale#

名前#

scale(3) - [MODEL_COMPONENTS] 基数の整数乗によって実数値をスケーリングする

概要#

    result = scale(x, i)
     elemental real(kind=KIND) function scale(x, i)

      real(kind=KIND),intent(in)   :: x
      integer(kind=**),intent(in)  :: i

特性#

  • x は任意の種類の実数型です。

  • i は任意の種類の整数型です。

  • 結果は、x と同じ種類の実数型です。

説明#

scale(3) は x * radix(x)**i を返します。

プラットフォームの基数(底)が 2 であることはほぼ確実であるため、scale(3) は一般的に x*2**i と同じです。

オプション#

  • x

    radix(x)**i を掛ける値。その型と種類は、その特性を持つ値の基数を決定し、結果の特性を決定するため、返される値がxの特性の範囲内にあるように注意する必要があります。

  • i

    マシンの基数を累乗するべき乗

結果#

戻り値は x * radix(x)**i であり、その値がxの型と種類で表現できることを前提としています。

#

サンプルプログラム

program demo_scale
implicit none
real :: x = 178.1387e-4
integer :: i = 5
   print *, scale(x,i), x*radix(x)**i
end program demo_scale

結果

    0.570043862      0.570043862

標準#

Fortran 95

参照#

digits(3)epsilon(3)exponent(3)fraction(3)huge(3)maxexponent(3)minexponent(3)nearest(3)precision(3)radix(3)range(3)rrspacing(3)set_exponent(3)spacing(3)tiny(3)

fortran-lang intrinsic descriptions (license: MIT) @urbanjost

set_exponent#

名前#

set_exponent(3) - [MODEL_COMPONENTS] 指定された指数を持つ実数値

概要#

    result = set_exponent(x, i)
     elemental real(kind=KIND) function set_exponent(x,i)

      real(kind=KIND),intent(in) :: x
      integer(kind=**),intent(in) :: i

特性#

  • x実数型です。

  • i整数型です。

  • **と指定された種類は、その型でサポートされている任意の種類です。

  • 戻り値は、x と同じ型および種類です。

説明#

set_exponent(3) は、小数部がxと同じで、指数部がiである実数を返します。

オプション#

  • x

    実数型である必要があります。

  • i

    整数型である必要があります。

結果#

戻り値は、x と同じ型および種類です。小数部がxと同じで、指数部がiである実数が返されます。これはfraction(x) * radix(x)**iです。

xの値がゼロの場合、結果はxと同じ値になります。

x が IEEE 無限大の場合、結果は IEEE NaN です。

xがIEEE NaNの場合、結果は同じNaNになります。

#

サンプルプログラム

program demo_setexp
implicit none
real :: x = 178.1387e-4
integer :: i = 17
   print *, set_exponent(x, i), fraction(x) * radix(x)**i
end program demo_setexp

結果

      74716.7891       74716.7891

標準#

Fortran 95

参照#

digits(3)epsilon(3)exponent(3)fraction(3)huge(3)maxexponent(3)minexponent(3)nearest(3)precision(3)radix(3)range(3)rrspacing(3)scale(3)spacing(3)tiny(3)

fortran-lang 固有関数の説明

spacing#

名前#

spacing(3) - [MODEL_COMPONENTS] 指定された型の2つの数値間の最小距離

概要#

    result = spacing(x)
     elemental real(kind=KIND) function spacing(x)

      real(kind=KIND), intent(in) :: x

特性#

  • x は任意の有効な種類の実数型です。

  • 結果は、入力引数xと同じ型です。

説明#

spacing(3) は、引数xとその同じ型の最も近い隣接数値間の距離を決定します。

オプション#

  • x

    実数型である必要があります。

結果#

xがゼロの値を持たず、IEEE無限大またはNaNでない場合、結果は、同じ型と種類で表現可能な値を想定して、xに最も近い値になります。

それ以外の場合は、値はtiny(x)と同じです。+ ゼロはtiny(x)を生成します。+ IEEE無限大はIEEE NaNを生成します。+ IEEE NaNの場合、そのNaNが返されます。

xに等しく近い2つの拡張モデル値がある場合、絶対値の大きい方の値が取得されます。

#

サンプルプログラム

program demo_spacing
implicit none
integer, parameter :: sgl = selected_real_kind(p=6, r=37)
integer, parameter :: dbl = selected_real_kind(p=13, r=200)

   write(*,*) spacing(1.0_sgl)
   write(*,*) nearest(1.0_sgl,+1.0),nearest(1.0_sgl,+1.0)-1.0

   write(*,*) spacing(1.0_dbl)
end program demo_spacing

結果

代表的な値…

     1.1920929E-07
      1.000000      1.1920929E-07
     0.9999999     -5.9604645E-08
     2.220446049250313E-016

標準#

Fortran 95

参照#

digits(3)epsilon(3)exponent(3)fraction(3)huge(3)maxexponent(3)minexponent(3)nearest(3)precision(3)radix(3)range(3)rrspacing(3)scale(3)set_exponent(3)tiny(3)

fortran-lang intrinsic descriptions (license: MIT) @urbanjost

digits#

名前#

digits(3) - [NUMERIC MODEL] 数値モデルにおける有効桁数

概要#

    result = digits(x)
     integer function digits(x)

      TYPE(kind=KIND),intent(in) :: x(..)

特性#

  • x整数または実数のスカラーまたは配列です。

  • 戻り値は、デフォルトの種類の整数です。

説明#

digits(3) は、x の内部モデル表現の有効桁数を返します。たとえば、32ビット浮動小数点表現を使用するシステムでは、デフォルトの実数型は24を返す可能性が高いです。

オプション#

  • x

    クエリする型と種類を持つ値

結果#

xの型と種類を持つ変数の有効桁数。

#

サンプルプログラム

program demo_digits
implicit none
integer :: i = 12345
real :: x = 3.143
doubleprecision :: y = 2.33d0
   print *,'default integer:', digits(i)
   print *,'default real:   ', digits(x)
   print *,'default doubleprecision:', digits(y)
end program demo_digits

結果

 >  default integer:          31
 >  default real:             24
 >  default doubleprecision:          53

標準#

Fortran 95

参照#

epsilon(3)exponent(3)fraction(3)huge(3)maxexponent(3)minexponent(3)nearest(3)precision(3)radix(3)range(3)rrspacing(3)scale(3)set_exponent(3)spacing(3)tiny(3)

fortran-lang intrinsic descriptions (license: MIT) @urbanjost

epsilon#

名前#

epsilon(3) - [数値モデル]イプシロン関数

概要#

    result = epsilon(x)
     real(kind=kind(x)) function epsilon(x)

      real(kind=kind(x),intent(in)   :: x(..)

特性#

  • x実数型です。スカラーまたは配列のいずれかです。

  • 結果は、xと同じ型とkind型パラメータを持つスカラーです。

説明#

epsilon(3) は、浮動小数点の相対精度を返します。これは、1+小さな数1と等しくならないような、1に対して無視できるほどの小さな数です。より正確には

   real( 1.0, kind(x)) + epsilon(x) /=  real( 1.0, kind(x))

これは、1.0から次に大きい浮動小数点数までの距離と考えることができます。

epsilon(3) の用途の1つは、計算が推定値からdelta以内になるまで検索するアルゴリズムに対してdelta値を選択することです。

deltaが小さすぎると、データ型の小数点の解像度よりも小さい値を合計する計算では変化しないため、アルゴリズムが停止しない可能性があります。

オプション#

  • x

    型は実数型である必要があります。

結果#

戻り値は、引数と同じ型です。

#

サンプルプログラム

program demo_epsilon
use,intrinsic :: iso_fortran_env, only : dp=>real64,sp=>real32
implicit none
real(kind=sp) :: x = 3.143
real(kind=dp) :: y = 2.33d0

   ! so if x is of type real32, epsilon(x) has the value 2**-23
   print *, epsilon(x)
   ! note just the type and kind of x matter, not the value
   print *, epsilon(huge(x))
   print *, epsilon(tiny(x))

   ! the value changes with the kind of the real value though
   print *, epsilon(y)

   ! adding and subtracting epsilon(x) changes x
   write(*,*)x == x + epsilon(x)
   write(*,*)x == x - epsilon(x)

   ! these next two comparisons will be .true. !
   write(*,*)x == x + epsilon(x) * 0.999999
   write(*,*)x == x - epsilon(x) * 0.999999

   ! you can calculate epsilon(1.0d0)
   write(*,*)my_dp_eps()

contains

   function my_dp_eps()
   ! calculate the epsilon value of a machine the hard way
   real(kind=dp) :: t
   real(kind=dp) :: my_dp_eps

      ! starting with a value of 1, keep dividing the value
      ! by 2 until no change is detected. Note that with
      ! infinite precision this would be an infinite loop,
      ! but floating point values in Fortran have a defined
      ! and limited precision.
      my_dp_eps = 1.0d0
      SET_ST: do
         my_dp_eps = my_dp_eps/2.0d0
         t = 1.0d0 + my_dp_eps
         if (t <= 1.0d0) exit
      enddo SET_ST
      my_dp_eps = 2.0d0*my_dp_eps

   end function my_dp_eps
end program demo_epsilon

結果

  1.1920929E-07
  1.1920929E-07
  1.1920929E-07
  2.220446049250313E-016
 F
 F
 T
 T
  2.220446049250313E-016

標準#

Fortran 95

参照#

digits(3)exponent(3)fraction(3)huge(3)maxexponent(3)minexponent(3)nearest(3)precision(3)radix(3)range(3)rrspacing(3)scale(3)set_exponent(3)spacing(3)tiny(3)

fortran-lang intrinsic descriptions (license: MIT) @urbanjost

huge#

名前#

huge(3) - [数値モデル]型の最大数

概要#

    result = huge(x)
     TYPE(kind=KIND) function huge(x)

      TYPE(kind=KIND),intent(in) :: x(..)

特性#

  • x は任意の実数型または整数型のスカラーまたは配列、および任意のkindです。

  • 結果は、入力xと同じ型とkindのスカラーになります。

説明#

huge(3) は、xのkindと型に対してオーバーフローにならない最大の数を返します。

オプション#

  • x

    x は、どのようなkindtypeのスカラーが問い合わせられているかを決定するためにのみ使用される任意の値です。その特性のみが使用されるため、定義されている必要はありません。

結果#

結果は、指定された型とkindでサポートされている最大値です。

戻り値がオーバーフローしないように、結果は入力と同じkindであることに注意してください。結果を変数に代入する際には、この点を考慮する必要があります。

#

サンプルプログラム

program demo_huge
implicit none
character(len=*),parameter :: f='(i2,1x,2(i11,1x),f14.0:,1x,l1,1x,a)'
integer :: i,j,k,biggest
real :: v, w
   ! basic
   print *, huge(0), huge(0.0), huge(0.0d0)
   print *, tiny(0.0), tiny(0.0d0)

   sum=0.0d0
   ! note subtracting one because counter is the end value+1 on exit
   do i=0,huge(0)-1
      sum=sum+i
   enddo
   write(*,*)'sum=',sum

   ! advanced
   biggest=huge(0)
   ! be careful of overflow when using integers in computation
   do i=1,14
      j=6**i   ! Danger, Danger
      w=6**i   ! Danger, Danger
      v=6.0**i
      k=v      ! Danger, Danger

      if(v.gt.biggest)then
         write(*,f) i, j, k, v, v.eq.w, 'wrong j and k and w'
      else
         write(*,f) i, j, k, v, v.eq.w
      endif

   enddo
end program demo_huge

結果

  2147483647  3.4028235E+38  1.797693134862316E+308
  1.1754944E-38  2.225073858507201E-308

    1      6           6             6. T
    2      36          36            36. T
    3      216         216           216. T
    4      1296        1296          1296. T
    5      7776        7776          7776. T
    6      46656       46656         46656. T
    7      279936      279936        279936. T
    8      1679616     1679616       1679616. T
    9      10077696    10077696      10077696. T
    10     60466176    60466176      60466176. T
    11     362797056   362797056     362797056. T
    12    -2118184960 -2147483648    2176782336. F wrong for j and k and w
    13     175792128  -2147483648   13060694016. F wrong for j and k and w
    14     1054752768 -2147483648   78364164096. F wrong for j and k and w

標準#

Fortran 95

参照#

digits(3)epsilon(3)exponent(3)fraction(3)maxexponent(3)minexponent(3)nearest(3)precision(3)radix(3)range(3)rrspacing(3)scale(3)set_exponent(3)spacing(3)tiny(3)

fortran-lang intrinsic descriptions (license: MIT) @urbanjost

maxexponent#

名前#

maxexponent(3) - [数値モデル]実数kindの最大指数

概要#

    result = maxexponent(x)
     elemental integer function maxexponent(x)

      real(kind=**),intent(in)   :: x

特性#

  • x は任意の実数kindの実数スカラーまたは配列です。

  • 結果は、デフォルトの整数型スカラーです。

説明#

maxexponent(3) は、xの型のモデルにおける最大指数を返します。

オプション#

  • x

    値を返す実数型のkindを選択するために使用される値です。

結果#

返される値は、問い合わせられた値のkindに対する最大指数です。

#

サンプルプログラム

program demo_maxexponent
use, intrinsic :: iso_fortran_env, only : real32,real64,real128
implicit none
character(len=*),parameter :: g='(*(g0,1x))'
   print  g,  minexponent(0.0_real32),   maxexponent(0.0_real32)
   print  g,  minexponent(0.0_real64),   maxexponent(0.0_real64)
   print  g,  minexponent(0.0_real128),  maxexponent(0.0_real128)
end program demo_maxexponent

結果

   -125 128
   -1021 1024
   -16381 16384

標準#

Fortran 95

参照#

digits(3)epsilon(3)exponent(3)fraction(3)huge(3)minexponent(3)nearest(3)precision(3)radix(3)range(3)rrspacing(3)scale(3)set_exponent(3)spacing(3)tiny(3)

fortran-lang intrinsic descriptions (license: MIT) @urbanjost

minexponent#

名前#

minexponent(3) - [数値モデル]実数kindの最小指数

概要#

    result = minexponent(x)
     elemental integer function minexponent(x)

      real(kind=**),intent(in) :: x

特性#

  • x は任意の実数kindの実数スカラーまたは配列です。

  • 結果は、デフォルトの整数型スカラーです。

説明#

minexponent(3) は、xの型のモデルにおける最小指数を返します。

オプション#

  • x

    値を返す実数型のkindを選択するために使用される値です。

結果#

返される値は、問い合わせられた値のkindに対する最大指数です。

#

サンプルプログラム

program demo_minexponent
use, intrinsic :: iso_fortran_env, only : &
 &real_kinds, real32, real64, real128
implicit none
real(kind=real32) :: x
real(kind=real64) :: y
    print *, minexponent(x), maxexponent(x)
    print *, minexponent(y), maxexponent(y)
end program demo_minexponent

期待される結果

        -125         128
       -1021        1024

標準#

Fortran 95

参照#

digits(3)epsilon(3)exponent(3)fraction(3)huge(3)maxexponent(3)nearest(3)precision(3)radix(3)range(3)rrspacing(3)scale(3)set_exponent(3)spacing(3)tiny(3)

fortran-lang intrinsic descriptions (license: MIT) @urbanjost

precision#

名前#

precision(3) - [数値モデル]実数kindの小数点精度

概要#

    result = precision(x)
     integer function precision(x)

      TYPE(kind=**),intent(in) :: x

特性#

  • x実数型または複素数型です。スカラーまたは配列のいずれかです。

  • 結果は、デフォルトの整数型スカラーです。

説明#

precision(3) は、xの型のモデルにおける小数点精度を返します。

オプション#

  • x

    引数の型とkindを使用して、どの数値モデルを問い合わせるかを決定します。引数の値は使用されません。定義されていない場合もあります。

結果#

xの型とkindの値の精度

#

サンプルプログラム

program demo_precision
use,intrinsic :: iso_fortran_env, only : dp=>real64,sp=>real32
implicit none
real(kind=sp)    :: x(2)
complex(kind=dp) :: y

   print *, precision(x), range(x)
   print *, precision(y), range(y)

end program demo_precision

結果

  >           6          37
  >          15         307

標準#

Fortran 95

参照#

digits(3)epsilon(3)exponent(3)fraction(3)huge(3)maxexponent(3)minexponent(3)nearest(3)radix(3)range(3)rrspacing(3)scale(3)set_exponent(3)spacing(3)tiny(3)

fortran-lang intrinsic descriptions (license: MIT) @urbanjost

radix#

名前#

radix(3) - [数値モデル] 数値モデルの基数

概要#

   result = radix(x)
    integer function radix(x)

     TYPE(kind=**),intent(in) :: x(..)

特性#

  • x は、任意の実数または整数型のスカラーまたは配列です。

  • 結果は、デフォルトの整数スカラーです。

説明#

radix(3) は、数値エンティティxを表す内部モデルの基数を返します。

位置的記数法では、基数または底は、数を表現するために使用される一意の数字の数(数字のゼロを含む)です。

この関数は、内部計算モデルを汎用的に表現するのに役立ちますが、すべての数値型について、一般的なプラットフォームでは2(バイナリマシンを表す)になります。

オプション#

  • x

    クエリする数値の種類を識別するために使用されます。

結果#

返された値は、数値値xが表す型の内部表現に使用される基数を示します。

#

サンプルプログラム

program demo_radix
implicit none
   print *, "The radix for the default integer kind is", radix(0)
   print *, "The radix for the default real kind is", radix(0.0)
   print *, "The radix for the doubleprecision real kind is", radix(0.0d0)
end program demo_radix

結果

 >  The radix for the default integer kind is           2
 >  The radix for the default real kind is           2
 >  The radix for the doubleprecision real kind is           2

標準#

Fortran 95

参照#

digits(3)epsilon(3)exponent(3)fraction(3)huge(3)maxexponent(3)minexponent(3)nearest(3)precision(3)range(3)rrspacing(3)scale(3)set_exponent(3)spacing(3)tiny(3)

fortran-lang intrinsic descriptions (license: MIT) @urbanjost

range#

名前#

range(3) - [数値モデル] 数値型の10進指数範囲

概要#

    result = range(x)
      integer function range (x)

       TYPE(kind=KIND),intent(in) :: x

特性#

  • x は、整数実数、または複素数型です。スカラーまたは配列です。

  • KIND は、x の型でサポートされる任意の kind です。

  • 結果は、デフォルトの整数型スカラーです。

説明#

range(3) は、x の型のモデルにおける10進指数範囲を返します。

x は、照会される型と kind を決定するためだけに使用されるため、値を定義する必要はありません。

オプション#

  • x

    型と kind がクエリに使用される値

結果#

ケース (i)

整数引数の場合は、結果は次の値になります。

    int (log10 (huge(x)))
ケース (ii)

実数引数の場合は、結果は次の値になります。

     int(min (log10 (huge(x)), -log10(tiny(x) )))
ケース (iii)

複素数引数の場合は、結果は次の値になります。

    range(real(x))

#

サンプルプログラム

program demo_range
use,intrinsic :: iso_fortran_env, only : dp=>real64,sp=>real32
implicit none
real(kind=sp)    :: x(2)
complex(kind=dp) :: y
   print *, precision(x), range(x)
   print *, precision(y), range(y)
end program demo_range

結果

 >            6          37
 >           15         307

標準#

Fortran 95

参照#

digits(3)epsilon(3)exponent(3)fraction(3)huge(3)maxexponent(3)minexponent(3)nearest(3)precision(3)radix(3)rrspacing(3)scale(3)set_exponent(3)spacing(3)tiny(3)

fortran-lang intrinsic descriptions (license: MIT) @urbanjost

tiny#

名前#

tiny(3) - [数値モデル] 実数型の最小の正の数

概要#

    result = tiny(x)
     real(kind=KIND) function tiny(x)

      real(kind=KIND) :: x

特性#

  • x は任意の実数のスカラーまたは配列です。

  • 結果は、x と同じ型と kind を持ちます。

説明#

tiny(3) は、x の型と kind の最小の正の数(ゼロ以外)を返します。

実数xの場合

   result = 2.0**(minexponent(x)-1)

オプション#

  • x

    kind がクエリするモデル型を決定するために使用される値

結果#

指定された kind の実数型の最小の正の値。

#

サンプルプログラム

program demo_tiny
implicit none
   print *, 'default real is from', tiny(0.0), 'to',huge(0.0)
   print *, 'doubleprecision is from ', tiny(0.0d0), 'to',huge(0.0d0)
end program demo_tiny

結果

 default real is from 1.17549435E-38 to 3.40282347E+38
 doubleprecision is from 2.2250738585072014E-308 to
 1.7976931348623157E+308

標準#

Fortran 95

参照#

digits(3)epsilon(3)exponent(3)fraction(3)huge(3)maxexponent(3)minexponent(3)nearest(3)precision(3)radix(3)range(3)rrspacing(3)scale(3)set_exponent(3)spacing(3)

fortran-lang intrinsic descriptions (license: MIT) @urbanjost