LF Fortran 95

EPSILON Function

Description

The EPSILON function returns a positive real value that is almost negligible compared to unity. It is the smallest value of x such that 1.+x is not equal to 1.

Syntax

EPSILON (x)

Arguments

x is an INTENT(IN) scalar or array of type REAL.

Result

The result is a scalar value of the same kind as x.

Its value is 21-p, where p is the number of bits in the fraction part of the physical representation of x.

Example

real(kind(1.d0)) :: d real(kind(1.e0)) :: r ! adding epsilon only changes the rightmost bit write(*,*) 1.d0+epsilon(d) ! writes 1.000000000000000 write(*,'(2z18.16)') 1.d0,1.d0+epsilon(d) ! show bits ! writes 3FF0000000000000 3FF0000000000001 write(*,*) 1.e0+epsilon(r) ! writes 1.00000012 write(*,'(2z10.8)') 1.e0,1.e0+epsilon(r) ! show bits ! writes 3F800000 3F800001