STR_ROUND: Approximate value of a floating point number
Original instructions
Function description
The STR_ROUND function provides the approximate value of a floating point number expressed in the form of a character string.
The additional parameters EN and ENO can be configured.
Representation in FBD
Representation:
Representation in LD
Representation:
Representation in IL
Representation:
LD Real_Str
STR_ROUND Pos, Rounded_Str
Representation in ST
Representation:
STR_ROUND(Real_Str, Pos, Rounded_Str);
Description of the parameters
The following table describes the input parameters:
Parameter
Type
Comment
Real_Str
Character string containing the real number.
Example: ’-1.1354942e-30’
Pos
Position from which the rounding off is performed. The position is calculated from the decimal separator, and the calculation is inclusive of the separator.
Example: 2
The following table describes the output parameters:
Parameter
Type
Comment
Rounded_Str
Result of truncation.
Example: with the data examples of the previous table, the result is the following ' -1.1000000e-30'
Runtime errors
The length of the original and resulting character strings must be between 15 and 255. Otherwise , the system bit %S15 is set to 1.
The parameter Pos must be between 0 and 8. Otherwise, the bit %S20 is set to 1. Special case for Pos = 0 and Pos = 8, the rounding off is not performed, Real_Str = Rounded_Str.
When the last character different to zero is greater than 5, the preceding character is incremented.