Skip to main content

valueIsNormal

Short summary​

This assertion method checks if the current value is a normal number (a finite non-zero/non-subnormal floating-point number) for details check IEEE 754

Parameters​

NameTypeCommentKind
currentValueLREALcurrent value to checkinput
messageAssertMessagemessage if the assertion is falseinput

Code​

Declaration​

METHOD valueIsNormal
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) OR_ELSE THIS^.isValueInfinite(currentValue)) THEN
THIS^.assertionWasWrong(message, THIS^.getDebugInfo('valueIsNormal'));
ELSE
currentValueAsDWord := ADR(currentValue);
IF ((currentValueAsDWord^ AND THIS^.MASK_FOR_EXPONENT) = THIS^.ZERO) THEN
THIS^.assertionWasWrong(message, THIS^.getDebugInfo('valueIsNormal'));
END_IF
END_IF