Prev Next Index-> contents reference index search external Up-> overview get_started start_embed near_equal_f overview-> License why Install get_started running files titles+headings cross format spellchecking latex other browser glossary wish_list whatsNew get_started-> start_simple start_head start_image start_pre start_font start_spell start_latex start_verbatim start_src start_embed start_multiple start_cref start_index start_embed-> view_near_equal_c near_equal_c view_near_equal_f near_equal_f near_equal_f Headings-> Syntax Purpose x y r a e Example

Determine if Two Values Are Nearly Equal

Syntax
e = near_equal_f(x, y, r, a)

Purpose
Returns true, if x is nearly equal to y and false otherwise.

x
The argument x has prototype       double precision x 
y
The argument y has prototype       double precision y 
r
The relative error criteria 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
The absolute error criteria 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
The return value e has prototype       logical e  If either the relative or absolute error condition is satisfied, it is true. Otherwise, it is false.

Example
The following is an example and test of 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 
Input File: getstarted/near_equal_f.f