BYTE_TO_LREALEX

The conversion of unsigned numbers into floating-point numbers of the type LREAL is not supported in TwinCAT 2 on the Arm® platform. Unsigned numbers with the most significant bit set may possibly be implicitly converted into negative floating-point numbers. The function described here allows the explicit conversion of the type BYTE into a positive floating-point number of the type LREAL in TwinCAT 2 (even if the most significant bit was set and without compiler warning). You only need this function to be able to compile converted TwinCAT 2 projects without changes in TwinCAT 3.
Unsigned numbers of the type BYTE are always (implicitly and explicitly) converted into positive floating-point numbers in TwinCAT 3. For this reason this function can be dispensed with.
 Return value
Name  | Type  | Description  | 
|---|---|---|
BYTE_TO_LREALEX  | LREAL  | 
  | 
 Inputs
VAR_INPUT
    in : BYTE;
END_VARName  | Type  | Description  | 
|---|---|---|
in  | BYTE  | 
  | 
Sample:
PROGRAM MAIN
VAR
    nByte  : BYTE := 16#FF;
    fLreal : LREAL := 0.0;
END_VARfLreal value  | Tc2.x ARM  | Tc2.x X86  | Tc3.x ARM, X86, X64  | 
|---|---|---|---|
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
*Conversion of unsigned integer to LREAL is not supported. The value is used as signed instead.
Requirements
Development environment  | Target platform  | PLC libraries to be integrated (category group)  | 
|---|---|---|
TwinCAT v3.1.0  | PC or CX (x86, x64, Arm®)  | Tc2_Utilities (System)  |