valueIsLessThan
Short summary
This assertion method checks if the current value is greater than the less value
Attention:
Any comparsion to NaN is FALSE that means if currentValue OR greaterValue
is NaN then is the assertion false.
For details check IEEE 754_ and the truth table below.
Attention: Every number is smaller than infinity except infinity, it's equal. Every number is greater than -infinity except -infinity, it's equal. For details check IEEE 754 and the truth table below.
truth table for special values
+----------------------+----------------------+---------------+
| currentValue | greaterValue | assertion |
+======================+======================+===============+
| NaN | Any value | FASLE |
+----------------------+----------------------+---------------+
| Any value | NaN | FALSE |
+----------------------+----------------------+---------------+
| infinity | Any value | FALSE |
+----------------------+----------------------+---------------+
| -infinity | NOT NaN | TRUE |
| | NOT -infinity | |
+----------------------+----------------------+---------------+
| NOT NaN | infinity | TRUE |
| NOT infinity | | |
+----------------------+----------------------+---------------+
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| currentValue | LREAL | current value to check | input |
| greaterValue | LREAL | greater than upper limit | input |
| message | AssertMessage | message if the assertion is false | input |
Code
Declaration
METHOD valueIsLessThan
VAR_INPUT
(* current value to check *)
currentValue :LREAL;
(* greater than upper limit *)
greaterValue :LREAL;
(* message if the assertion is false *)
message :AssertMessage;
END_VAR
Implementation
IF (
THIS^.isValueNaN(currentValue)
OR_ELSE THIS^.isValueNaN(greaterValue)
OR_ELSE THIS^.isValuePositiveInfinite(currentValue)
OR_ELSE THIS^.isValueNegativeInfinite(greaterValue)
) THEN
THIS^.assertionWasWrong(message, THIS^.getDebugInfo('valueIsLessThan'));
ELSIF (
THIS^.isValuePositiveInfinite(greaterValue)
OR_ELSE THIS^.isValueNegativeInfinite(currentValue)
) THEN
RETURN;
ELSIF (currentValue >= greaterValue) THEN
THIS^.assertionWasWrong(message, THIS^.getDebugInfo('valueIsLessThan'));
END_IF