EXPONENT(3) - [MODEL:COMPONENTS] Exponent of floating-point number
result = exponent(x)
elemental integer function exponent(x)real(kind=**),intent(in) :: x
o X shall be of type real of any valid kind o the result is a default integer type
EXPONENT(3) returns the value of the exponent part of X, provided the exponent is within the range of default integers.
o X : the value to query the exponent of
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).
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_exponentResults:
> 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 intrinsic descriptions
Nemo Release 3.1 | exponent (3fortran) | November 02, 2024 |