Tests two real numberes for equality using a tolerance if provided by the user, or selecting a tolerance automatically otherwise.
n = eq(f1, f2, eps)
Where:
f1
: First real number to compare for equality.f2
: Second real to compare for equality.eps
: User selected tolerance for the comparison. If not provided it
will be selected automatically.It returns True both numbers are equal according to the selected tolerance and False otherwise
The following program tests if two real numbers are equal:
PROGRAM eqExample
USE FU_Numbers, ONLY: eq
IMPLICIT NONE
WRITE(*,*) eq(5., 5.00001, 0.000000001)
WRITE(*,*) eq(5., 5.00001, 0.001)
WRITE(*,*) eq(5., 5.00001)
END PROGRAM eqExample
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=sp), | intent(in) | :: | x1 |
First real value to compare for equality. |
||
real(kind=sp), | intent(in) | :: | x2 |
Second real value to compare for equality. |
||
real(kind=sp), | intent(in), | optional | :: | eps |
User selected tolerance for the comparison. If not provided it will be selected automatically. |
True if both numbers are equal according to the selected tolerance. False otherwise.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in) | :: | x1 |
First real value to compare for equality. |
||
real(kind=dp), | intent(in) | :: | x2 |
Second real value to compare for equality. |
||
real(kind=dp), | intent(in), | optional | :: | eps |
User selected tolerance for the comparison. If not provided it will be selected automatically. |
True if both numbers are equal according to the selected tolerance. False otherwise.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=qp), | intent(in) | :: | x1 |
First real value to compare for equality. |
||
real(kind=qp), | intent(in) | :: | x2 |
Second real value to compare for equality. |
||
real(kind=qp), | intent(in), | optional | :: | eps |
User selected tolerance for the comparison. If not provided it will be selected automatically. |
True if both numbers are equal according to the selected tolerance. False otherwise.