F_BA_RoundLREAL

The F_BA_RoundLREAL function rounds the input variable fIn to the decimal place specified by nDecimalPlace. This function can also be used for REAL data types. An instance of the function LREAL_TO_FMTSTR from the Tc2_Utilities.lib library is used internally in the function.
fIn | nDecimalPlace | F_BA_RoundLREAL |
|---|---|---|
12345.987654321 | 0 | 12346 |
12345.987654321 | 1 | 12346.0 |
12345.987654321 | 2 | 12345.99 |
12345.987654321 | 3 | 12345.988 |
12345.987654321 | 4 | 12345.9877 |
12345.987654321 | 5 | 12345.98765 |
12345.987654321 | >=6 | 12345.98765 |
-12345.987654321 | 0 | -12346 |
-12345.987654321 | 1 | -12346.0 |
-12345.987654321 | 2 | -12345.99 |
-12345.987654321 | 3 | -12345.988 |
-12345.987654321 | 4 | -12345.9877 |
-12345.987654321 | 5 | -12345.98765 |
-12345.987654321 | >=6 | -12345.98765 |
Syntax
FUNCTION F_BA_RoundLREAL : LREAL
VAR_INPUT
fIn : LREAL;
nDecimalPlace : UDINT;
END_VAR
Inputs
Name | Type | Description |
|---|---|---|
fIn | REAL | Floating-point number that is to be formatted. |
nDecimalPlace | REAL | Decimal place to which to round. The maximum number of decimal places is limited to 5. |
Requirements
Development environment | Required PLC library |
|---|---|
TwinCAT from v3.1.4024.62 | Tc3_BA2 from v5.5.17.0 |