Manual Reference Pages  - exponent (3fortran)

NAME

EXPONENT(3) - [MODEL_COMPONENTS] Exponent of floating-point number

SYNOPSIS

result = exponent(x)

         elemental integer function exponent(x)

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

CHARACTERISTICS

o X shall be of type real of any valid kind
o the result is a default integer type

DESCRIPTION

EXPONENT(3) returns the value of the exponent part of X, provided the exponent is within the range of default integers.

OPTIONS

o X : the value to query the exponent of

RESULT

EXPONENT(3) returns the value of the exponent part of X

If X is zero the value returned is zero.

If X is an IEEE infinity or NaN, the result has the value HUGE(0).

EXAMPLES

Sample program:

    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])
       ! beware of overflow, it may occur silently
       !print *, 2**[10.0,100.0,1000.0,-10000.0]
       print *, exponent(huge(0.0))
       print *, exponent(tiny(0.0))
    end program demo_exponent

Results:

     >            4           7          10          14
     >          128
     >         -125

STANDARD

Fortran 95

SEE ALSO

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 intrinsic descriptions


Nemo Release 3.1 exponent (3fortran) April 28, 2024
Generated by manServer 1.08 from 6de31ec8-eedb-4e6d-9db4-3e9e8917207b using man macros.