isInf(Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

ALL

Firmware version:

3.10 / 1.00.00


This function checks if the provided value is infinite.

This should be used to verify results of calculations where it is possible to have an illegal value.

 
Note: Besides the functions that return infinite in case of an error, it is also possible to get infinite using normal operators, if either a result is too large, or e.g. by dividing with 0.

 

Note: This function works with DOUBLE, but can also work with FLOAT as described in the Floating-point math introductory section.

 

Input:

V : DOUBLE

Value to check.

 

Returns: BOOL

True if the value if +Infinity or - Infinity, False otherwise.

 

Declaration:

FUNCTION isInf : BOOL;
VAR_INPUT
v : DOUBLE;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
INCLUDE math.inc
 
PROGRAM test;
VAR
  a : DOUBLE;
  b : DOUBLE;
END_VAR;
 
a := 2.0;
WHILE NOT isInf(v := a) DO
  b := a;
  a := a * 2.0;
END_WHILE;
DebugMsg(message := " b = " + doubleToStr(v := b));
 
END_PROGRAM;