valueIsPositive
Short summary
This assertion method checks if the current value is positve
Attention:
Any comparsion to NaN is FALSE that means if currentValue
is NaN then is the assertion false.
For details check IEEE 754_.
Attention:
currentValue has the value infinity means the assertion is true.
currentValue has the value -infinity means the assertion is false.
currentValue has the +0.0 means the assertion is true.
currentValue has the value -0.0 means the assertion is false.
For details check IEEE 754.
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| currentValue | LREAL | current value to check | input |
| message | AssertMessage | message if the assertion is false | input |
Code
Declaration
{attribute 'analysis' := '-56'}
METHOD valueIsPositive
VAR_INPUT
(* current value to check *)
currentValue :LREAL;
(* message if the assertion is false *)
message :AssertMessage;
END_VAR
VAR
(* just to cast ``currentValue`` *)
currentValueAsDWord :POINTER TO LWORD;
END_VAR
Implementation
IF (THIS^.isValueNaN(currentValue)) THEN
THIS^.assertionWasWrong(message, THIS^.getDebugInfo('valueIsPositive'));
ELSE
currentValueAsDWord := ADR(currentValue);
IF ((currentValueAsDWord^ AND THIS^.MASK_FOR_SIGN_BIT) = THIS^.MASK_FOR_SIGN_BIT) THEN
THIS^.assertionWasWrong(message, THIS^.getDebugInfo('valueIsPositive'));
END_IF
END_IF