IsRelEqual

IsRelEqual 1:

The IsRelEqual method checks whether two floating-point numbers of type “LREAL” fall within a specified tolerance. If both values are greater than the value specified in absCompScale, the relative deviation between the two values is checked against the tolerance. If any of the values fall below the tolerance, an absolute comparison is performed. Among other things, this method is used in the AssertRelEqual method.

Syntax

METHOD IsRelEqual : bool
VAR_INPUT
    actual         : LREAL;
    expected     : LREAL;
    precision     : LREAL;
END_VAR
VAR CONSTANT
    absCompScale : LREAL := 1E-12;
END_VAR

IsRelEqual 2: Inputs

Name

Type

Description

actual

LREAL

Value determined by executing the test case

expected

LREAL

Expected value for the test case

precision

LREAL

Relative tolerance for comparison

IsRelEqual 3: Return value

Name

Type

Description

IsRelEqual

BOOL

Returns the Boolean result of the comparison.

Example

IsRelEqual (actual:= result, expected:= expectedValue, precision)