Domain and Range of FORTRAN Natural Log Functions

ID: Q35872


The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, versions 4.0, 4.01, 4.1, 5.0, 5.1
  • Microsoft FORTRAN PowerStation for MS-DOS, versions 1.0, 1.0a
  • Microsoft Fortran Powerstation 32 for Windows NT, versions 1.0, 4.0


SUMMARY

The program below demonstrates the use of the exp (e**n) and log FORTRAN natural logarithm functions, using the limits of real*4 (or real) and real*8 values. Both the domain and range of these functions must be valid real*4 values for exp and log, and real*8 values for dexp and dlog. Consequently, the highest acceptable argument to the exp functions is the natural log of the maximum real number for the respective floating-point precisions.


MORE INFORMATION

The following demonstrates this information:


c Program to manipulate natural log and exp functions with greatest and
c smallest real*4 and real*8 values. The 16th decimal digit displayed
c exceeds the 15 significant digits, and may not be accurate.

c Define extreme real*4 and real*8 values, and double- and
c single-precision "e"

      real*8 maxr8, minr8, pos0r8, neg0r8, e8
      real*4 maxr4, minr4, pos0r4, neg0r4, e4

      maxr8  =  1.7976931348623156d+308
      minr8  = -1.7976931348623156d+308
      pos0r8 =  2.23d-308
      neg0r8 = -2.23d-308
      e8     = dexp(1)

      maxr4  =  1.701411e+38
      minr4  = -1.701411e+38
      pos0r4 =  1.701411e-38
      neg0r4 = -1.701411e-38
      e4     = exp(1)

      write(*,*)
      write(*,*) 'Program to demonstrate use of natural log functions'
      write(*,*) 'with domain & range values at floating point limits.'
      write(*,*)
      write(*,*) 'There are 7 significant decimal digits in a real*4'
      write(*,*) '15 (or 16) significant decimal digits in a real*8.'
      write(*,*)
      write(*,*) 'The Intel coprocessor reference states that the'
      write(*,*) 'range of double precision (real*8) values is'
      write(*,*) 'approximately +/-2.23e-308 to +/-1.80e308. The'
      write(*,*) 'larger real*8 has been carried out to additional'
      write(*,*) 'digits of signifigance below.'
      write(*,*)
      write(*,*) 'Press ENTER to continue...'
      read(*,*)
      write(*,*)
      write(*,*) 'Display extreme real*4 and real*8 values:'
      write(*,*)
      write(*,*) 'max real*8           =  ', maxr8
      write(*,*) 'min real*8           =  ', minr8
      write(*,*) 'smallest positive r8 =  ', pos0r8
      write(*,*) 'smallest negative r8 =  ', neg0r8
      write(*,*)
      write(*,*) 'max real*4           = ', maxr4
      write(*,*) 'min real*4           = ', minr4
      write(*,*) 'smallest positive r4 = ', pos0r4
      write(*,*) 'smallest negative r4 = ', neg0r4
      write(*,*)
      write(*,*) 'Press ENTER to continue...'
      read(*,*)
      write(*,*) 'Perform real*4 and real*8 natural log and'
      write(*,*) 'exponentiation functions on limit values:'
      write(*,*)
      write(*,*) 'dexp(1) = real*8 e   =  ', e8
      write(*,*) 'dlog(maxr8)          =  ', dlog(maxr8)
      write(*,*) 'dexp(dlog(maxr8))    =  ', dexp(dlog(maxr8))
      write(*,*) 'dlog(smallest pos r8)=  ', dlog(pos0r8)
      write(*,*) 'dexp(minr8)          =  ', dexp(minr8)
      write(*,*)
      write(*,*) 'exp(1) = real*4 e    = ', e4
      write(*,*) 'log(maxr4)           = ', log(maxr4)
      write(*,*) 'exp(log(maxr4))      = ', exp(log(maxr4))
      write(*,*) 'log(smallest pos r8) = ', log(pos0r4)
      write(*,*) 'exp(minr4)           = ', exp(minr4)
      write(*,*)
      write(*,*) 'Program completed. Good-bye.'
      end 

Additional query words: 1.00 4.00 4.10 5.00 5.10 kbinf

Keywords : kbcode kbFortranPS kbLangFortran
Version : :1.0,1.0a,4.0,4.01,4.1,5.0,5.1
Platform : MS-DOS NT WINDOWS
Issue type :


Last Reviewed: November 2, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.