Prev | Next | near_equal_f |
e = near_equal_f(x, y, r, a)
x
is nearly equal to
y
and false otherwise.
x
has prototype
double precision x
y
has prototype
double precision y
r
has prototype
double precision r
It must be greater than or equal zero.
The relative error condition is satisfied if
@[@
| x - y | \leq r ( |x| + |y| )
@]@
where @(@
\leq
@)@ denotes less than or equal.
a
has prototype
double precision a
It must be greater than or equal zero.
The absolute error condition is satisfied if
@[@
| x - y | \leq a
@]@
e
has prototype
logical e
If either the relative or absolute error condition is satisfied,
it is true.
Otherwise, it is false.
near_equal_f
.
It returns true if the test succeeds and false if it fails.
c Use integer for return value so that this function is callable by C
integer function ok_near_equal_f()
double precision x, y, r, a
logical near_equal_f
external near_equal_f
x = 1.1
y = 1.2
r = .1
a = 0.
if( near_equal_f(x, y, r, a) ) then
ok_near_equal_f = 1
else
ok_near_equal_f = 0
endif
end