ne Interface

public interface ne

Tests two real numberes for inequality using a tolerance if provided by the user, or selecting a tolerance automatically otherwise.

Syntax

 n = ne(f1, f2, eps)

Where:

  • f1: First real number to compare for inequality.
  • f2: Second real to compare for inequality.
  • eps: User selected tolerance for the comparison. If not provided it will be selected automatically.

It returns True both numbers are not equal according to the selected tolerance and False otherwise

Example

The following program tests if two real numbers are not equal:

 PROGRAM neExample
    USE FU_Numbers, ONLY: ne
    IMPLICIT NONE
    WRITE(*,*) ne(5., 5.00001, 0.000000001)
    WRITE(*,*) ne(5., 5.00001, 0.001)
    WRITE(*,*) ne(5., 5.00001)
 END PROGRAM neExample

Contents


Module Procedures

private elemental function ne_sp(x1, x2, eps) result(res)

Arguments

Type IntentOptional Attributes Name
real(kind=sp), intent(in) :: x1

First real value to compare for inequality.

real(kind=sp), intent(in) :: x2

Second real value to compare for inequality.

real(kind=sp), intent(in), optional :: eps

User selected tolerance for the comparison. If not provided it will be selected automatically.

Return Value logical

True if the numbers are not equal according to the selected tolerance. False otherwise.

private elemental function ne_dp(x1, x2, eps) result(res)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: x1

First real value to compare for inequality.

real(kind=dp), intent(in) :: x2

Second real value to compare for inequality.

real(kind=dp), intent(in), optional :: eps

User selected tolerance for the comparison. If not provided it will be selected automatically.

Return Value logical

True if the numbers are not equal according to the selected tolerance. False otherwise.

private elemental function ne_qp(x1, x2, eps) result(res)

Arguments

Type IntentOptional Attributes Name
real(kind=qp), intent(in) :: x1

First real value to compare for inequality.

real(kind=qp), intent(in) :: x2

Second real value to compare for inequality.

real(kind=qp), intent(in), optional :: eps

User selected tolerance for the comparison. If not provided it will be selected automatically.

Return Value logical

True if the numbers are not equal according to the selected tolerance. False otherwise.