The AHA Model  Revision: 12809
Reference implementation 04 (HEDG02_04)
commondata::float_equal Interface Reference

Check if two real values are nearly equal using the commondata::is_near_zero(). Thus function can be used for comparing two real values like this: More...

Collaboration diagram for commondata::float_equal:

Public Member Functions

elemental logical function float_equal_srp (value1, value2, epsilon)
 Check if two real values are nearly equal using the commondata::is_near_zero(). Thus function can be used for comparing two real values like the below. The exact comparison (incorrect due to possible rounding): More...
 
elemental logical function float_equal_hrp (value1, value2, epsilon)
 Check if two real values are nearly equal using the commondata::is_near_zero(). Thus function can be used for comparing two real values like the below. The exact comparison (incorrect due to possible rounding): More...
 

Detailed Description

Check if two real values are nearly equal using the commondata::is_near_zero(). Thus function can be used for comparing two real values like this:

  • The exact float comparison (incorrect due to possible rounding):
    if ( a == b ) ...
  • should be substituted by such comparison:
    if ( float_equal(a, b) ) ...

See the backend procedures commondata::float_equal_srp() and commondata::float_equal_hrp() for details.

Definition at line 5406 of file m_common.f90.

Member Function/Subroutine Documentation

◆ float_equal_srp()

elemental logical function commondata::float_equal::float_equal_srp ( real(srp), intent(in)  value1,
real(srp), intent(in)  value2,
real(srp), intent(in), optional  epsilon 
)

Check if two real values are nearly equal using the commondata::is_near_zero(). Thus function can be used for comparing two real values like the below. The exact comparison (incorrect due to possible rounding):

if ( a == b ) ...

should be substituted by such comparison:

if ( float_equal(a, b, 0.00001) ) ...

There is also a user defined operator .feq. for approximate float point equality. It differs from this function in that the later allows to set an arbitrary epsilon tolerance value whereas the operator does not (it uses the default epsilon based on the intrinsic tiny() function.

Note
This is the standard precision function (commondata::srp).
Parameters
[in]value1value1 The first value for comparison.
[in]value2value2 The second value for comparison.
[in]epsilonepsilon optional (very small) tolerance value.
Returns
TRUE if the values value1 and value2 are nearly equal.

Definition at line 6268 of file m_common.f90.

◆ float_equal_hrp()

elemental logical function commondata::float_equal::float_equal_hrp ( real(hrp), intent(in)  value1,
real(hrp), intent(in)  value2,
real(hrp), intent(in), optional  epsilon 
)

Check if two real values are nearly equal using the commondata::is_near_zero(). Thus function can be used for comparing two real values like the below. The exact comparison (incorrect due to possible rounding):

if ( a == b ) ...

should be substituted by such comparison:

if ( float_equal(a, b, 0.00001) ) ...

There is also a user defined operator .feq. for approximate float point equality. It differs from this function in that the later allows to set an arbitrary epsilon tolerance value whereas the operator does not (it uses the default epsilon based on the intrinsic tiny() function.

Note
This is the high precision function (commondata::hrp).
Parameters
[in]value1value1 The first value for comparison.
[in]value2value2 The second value for comparison.
[in]epsilonepsilon optional (very small) tolerance value.
Returns
TRUE if the values value1 and value2 are nearly equal.

Definition at line 6306 of file m_common.f90.


The documentation for this interface was generated from the following file: