Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Plant SCADA

IntToReal

  • Last UpdatedJul 18, 2023
  • 2 minute read

Converts an integer into a real (floating point) number.

When calling statements such as comparison or arithmetic operations that involve a mixture of variables of REAL and INT data types, there is no need to explicitly convert the variable of INT data type to REAL data type using the IntToReal function. Plant SCADA will automatically convert variables of INT data type to REAL data type before the operation is carried out.

However, if the expression only consists of variables of INT data type, the result of the expression will remain as INT data type and be subjected to its limitations such as integer overflow and wraparound. This does not change even if the expression is to be assigned to a variable of REAL data type.

If you want to increase the range of the expression, you will need to convert at least one of its operands to REAL data type using the IntToReal function (see Example 2 below).

Syntax

IntToReal(Number)

Number:

The integer to convert.

Return Value

The real number.

RealToStr, StrToInt

Example 1

! Sets Variable to 45.0
Variable=IntToReal(45);
! Sets Variable to -45.0
Variable=IntToReal(-45);

Example 2

INT nVar1 = 1000000001;
INT nVar2 = 2000000002;
REAL rVar1 = 1.000001;
REAL rVar2 = 0.0;


// rVar2 = 1000000002.000001, IntToReal is not needed when operands are mixture of INT and REAL data types
rVar2 = nVar1 + rVar1;

// rVar2 = -1294967293.0, result is wrapped around due to range overflow of integer data type
rVar2 = nVar1 + nVar2;

// rVar2 = 3000000003.0, result is prompted to REAL data type when one of the INT operands is converted
rVar2 = nVar1 + IntToReal(nVar2);

See Also

Converting and Formatting Cicode Variables

Miscellaneous Functions

In This Topic
TitleResults for “How to create a CRG?”Also Available in