Test if two real values are equal. Uses an epsilon value to account for floating point error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | res | Real value result being tested. |
||
real(kind=wp), | intent(in) | :: | tgt | Target real value to compare result to. |
||
real(kind=wp) | :: | eps | Allowed margin of error |
Return whether both values are equal.
function realEq(res, tgt, eps) result(comp)
!! Test if two real values are equal. Uses an epsilon value to account
!! for floating point error.
real(kind=wp), intent(in) :: res
!! Real value result being tested.
real(kind=wp), intent(in) :: tgt
!! Target real value to compare result to.
real(kind=wp) :: eps
!! Allowed margin of error
logical :: comp
!! Return whether both values are equal.
comp = abs(res-tgt) < eps
end function realEq