Typecast FLOAT(expression)

Top  Previous  Next

The FLOAT typecast operator is used to convert an expression to a FLOAT type. This typecast is done numerically so that for example typecasting an integer value of 56 will yield a floating-point value of equally 56.0.

 

 

Example:

INCLUDE rtcu.inc
 
VAR
  a : DINT;
  f : FLOAT;
END_VAR;
 
PROGRAM test;
 
// Convert 'a' which is a DINT type to a FLOAT
a := 4711; // Integer value to convert.

f := FLOAT(a); // f will now contain 4711.00
 
END_PROGRAM;