# tem_float_module Module

Floating point numbers need a special treatment due to their storage format.

Some people already made up their minds about those things, thus that we can make use of their findings. See further: - http://www.floating-point-gui.de/errors/comparison/ - https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ - http://www.ssec.wisc.edu/~paulv/Fortran90/Utility/Compare_Float_Numbers.f90.html

Most of this modules code traces back to the work of Paul van Delst, CIMSS/SSEC, paul.vandelst@ssec.wisc.edu

## Interfaces

• ### private elemental function equal(a, b) result(res)

Relational operator to test the equality of floating point numbers.

#### Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: a

Floating point value to be compared.

real(kind=rk), intent(in) :: b

Floating point value to be compared.

#### Return Value logical

The result is a logical value indicating whether the operands are equal to within numerical precision.

• ### private pure function equal_array(a, b) result(res)

Relational operator to test the equality of two arrays of floating point numbers.

#### Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: a(:)

Floating point array to be compared.

real(kind=rk), intent(in) :: b(:)

Floating point array to be compared.

#### Return Value logical

The result is a logical value indicating whether the operands are equal to within numerical precision.

• ### private elemental function notEqual(a, b) result(res)

Relational operator to test the not-equality of floating point numbers.

#### Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: a

Floating point value to be compared.

real(kind=rk), intent(in) :: b

Floating point value to be compared.

#### Return Value logical

The result is a logical value indicating whether the operands are not equal to within numerical precision.

• ### private pure function notEqual_array(a, b) result(res)

Relational operator to test the not-equality of two floating point arrays.

#### Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: a(:)

Floating point array to be compared.

real(kind=rk), intent(in) :: b(:)

Floating point array to be compared.

#### Return Value logical

The result is a logical value indicating whether the operands are not equal to within numerical precision.

• ### private elemental function greaterThan(a, b) result(res)

Relational operator to test if one operand is greater than another.

#### Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: a

Floating point value to be compared.

real(kind=rk), intent(in) :: b

Floating point value to be compared.

#### Return Value logical

The result is a logical value indicating whether the operand a is greater than b by more than the spacing between representable floating point numbers.

• ### private elemental function greaterThanOrEqual(a, b) result(res)

Relational operator to test if one operand is greater than or equal to another.

#### Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: a

Floating point value to be compared.

real(kind=rk), intent(in) :: b

Floating point value to be compared.

#### Return Value logical

The result is a logical value indicating whether the operand a is greater than or equal to b by more than the spacing between representable floating point numbers.

• ### private elemental function lessThan(a, b) result(res)

Relational operator to test if one operand is less than another.

#### Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: a

Floating point value to be compared.

real(kind=rk), intent(in) :: b

Floating point value to be compared.

#### Return Value logical

The result is a logical value indicating whether the operand a is less than b by more than the spacing between representable floating point numbers.

• ### private elemental function lessThanOrEqual(a, b) result(res)

Relational operator to test if one operand is less than or equal to another.

#### Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: a

Floating point value to be compared.

real(kind=rk), intent(in) :: b

Floating point value to be compared.

#### Return Value logical

The result is a logical value indicating whether the operand a is less than or equal to b by more than the spacing between representable floating point numbers.

## Functions

### private elemental function equal(a, b) result(res)

Relational operator to test the equality of floating point numbers.

#### Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: a

Floating point value to be compared.

real(kind=rk), intent(in) :: b

Floating point value to be compared.

#### Return Value logical

The result is a logical value indicating whether the operands are equal to within numerical precision.

### private pure function equal_array(a, b) result(res)

Relational operator to test the equality of two arrays of floating point numbers.

#### Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: a(:)

Floating point array to be compared.

real(kind=rk), intent(in) :: b(:)

Floating point array to be compared.

#### Return Value logical

The result is a logical value indicating whether the operands are equal to within numerical precision.

### private elemental function notEqual(a, b) result(res)

Relational operator to test the not-equality of floating point numbers.

#### Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: a

Floating point value to be compared.

real(kind=rk), intent(in) :: b

Floating point value to be compared.

#### Return Value logical

The result is a logical value indicating whether the operands are not equal to within numerical precision.

### private pure function notEqual_array(a, b) result(res)

Relational operator to test the not-equality of two floating point arrays.

#### Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: a(:)

Floating point array to be compared.

real(kind=rk), intent(in) :: b(:)

Floating point array to be compared.

#### Return Value logical

The result is a logical value indicating whether the operands are not equal to within numerical precision.

### private elemental function greaterThan(a, b) result(res)

Relational operator to test if one operand is greater than another.

#### Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: a

Floating point value to be compared.

real(kind=rk), intent(in) :: b

Floating point value to be compared.

#### Return Value logical

The result is a logical value indicating whether the operand a is greater than b by more than the spacing between representable floating point numbers.

### private elemental function greaterThanOrEqual(a, b) result(res)

Relational operator to test if one operand is greater than or equal to another.

#### Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: a

Floating point value to be compared.

real(kind=rk), intent(in) :: b

Floating point value to be compared.

#### Return Value logical

The result is a logical value indicating whether the operand a is greater than or equal to b by more than the spacing between representable floating point numbers.

### private elemental function lessThan(a, b) result(res)

Relational operator to test if one operand is less than another.

#### Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: a

Floating point value to be compared.

real(kind=rk), intent(in) :: b

Floating point value to be compared.

#### Return Value logical

The result is a logical value indicating whether the operand a is less than b by more than the spacing between representable floating point numbers.

### private elemental function lessThanOrEqual(a, b) result(res)

Relational operator to test if one operand is less than or equal to another.

#### Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in) :: a

Floating point value to be compared.

real(kind=rk), intent(in) :: b

Floating point value to be compared.

#### Return Value logical

The result is a logical value indicating whether the operand a is less than or equal to b by more than the spacing between representable floating point numbers.