ieee_logb

Date:

10-12-2011

NAME

IEEE_LOGB - Returns the unbiased exponent of x

SYNOPSIS

IEEE_LOGB ([X=]x)

IMPLEMENTATION

Cray Linux Environment (CLE)

STANDARDS

Fortran

IEEE Standard for Binary Floating-point Arithmetic

DESCRIPTION

The IEEE_LOGB intrinsic function returns the unbiased exponent of x. This function corresponds to the logb function described in the IEEE standard appendix of recommended functions.

The IEEE_LOGB function accepts the following argument:

x

Must be of type real.

IEEE_LOGB is an elemental function. The name of this intrinsic cannot be passed as an argument.

IEEE_LOGB should not be invoked if IEEE_SUPPORT_DATATYPE(x) has the value false.

NOTES

The IEEE intrinsic procedures use the named constants contained in a system module, so you must include the following statement in your program:

USE, INTRINSIC :: IEEE_ARITHMETIC

RETURN VALUES

The result type has the same type and kind type parameter value as x.

If x is not zero, infinity, or a NaN, the result is the value of the unbiased exponent of x.

If x== 0, the result is -infinity if IEEE_SUPPORT_INF(x) is true and -HUGE(x), otherwise. The IEEE_DIVIDE_BY_ZERO signals.

EXAMPLES

Example 1:

USE, INTRINSIC :: IEEE_ARITHMETIC
REAL   x

   ! Compute X.
PRINT *, "Unbiased exponent of X:", IEEE_LOGB(x)

The PRINT statement prints the unbiased exponent of x as a default real value as long as x is not one of the exceptional values noted in the RETURN VALUES section.

Example 2:

Example 2. Program ieexp.f90 uses several intrinsic procedures:

USE, INTRINSIC :: IEEE_ARITHMETIC
REAL(8) X
PRINT *," TEST EXPONENT and IEEE_LOGB of HUGE"
X = HUGE(1.0_8)
! HUGE scaled to 0.xxx
PRINT *," F90 EXPONENT of x=",EXPONENT(x)
! HUGE scaled to x.xx
PRINT *," Unbiased IEEE_LOGB of x=",IEEE_LOGB(x)
PRINT *," TEST EXPONENT and IEEE_LOGB of TINY"
X = TINY(1.0_8)
! TINY scaled to 0.xxx
PRINT *," F90 EXPONENT of x=",EXPONENT(x)
! TINY scaled to x.xx
PRINT *," Unbiased IEEE_LOGB of x=",IEEE_LOGB(x)
END

The output from this program is as follows:

TEST EXPONENT and IEEE_EXPONENT of HUGE
F90 EXPONENT of x= 1024
Unbiased IEEE_EXPONENT of x= 1023
TEST EXPONENT and IEEE_EXPONENT of TINY
F90 EXPONENT of x= -1021
Unbiased IEEE_EXPONENT of x= -1022

SEE ALSO

ieee_support_inf(3i) logb(3c)