beautypg.com

Real_to-/ lreal_to conversions, L-force | plc designer – Lenze PLC Designer PLC Designer (R2-x) User Manual

Page 492

background image

L-force | PLC Designer

IEC Operators and additional norm extending functions

490

DMS 3.2 EN 02/2011 TD29

9.9.5

REAL_TO-/ LREAL_TO Conversions

Converting from the variable type REAL or LREAL to a different type:

The value will be rounded up or down to the nearest whole number and converted
into the new variable type. Exceptions to this are the variable types STRING, BOOL,
REAL and LREAL.

Please regard at a conversion to type STRING that the total number of digits is limited
to 16. If the (L)REAL-number has more digits, then the sixteenth will be rounded. If the
length of the STRING is defined to short, it will be cut beginning from the right end.

When you perform a type conversion from a larger to a smaller type, you risk losing
some information.

Example in ST:

i := REAL_TO_INT(1.5); (* Result is 2 *)

j := REAL_TO_INT(1.4); (* Result is 1 *)

i := REAL_TO_INT(-1.5); (* Result is -2 *)

j := REAL_TO_INT(-1.4); (* Result is -1 *)

Example in IL:

LD 2.7

REAL_TO_INT

GE %MW8

Example in FBD: