FormatFloat, FormatFloatL
The FormatFloat and FormatFloatL instructions are used to convert a floating point value into a string. The difference between the two instructions is that in addition to the behavior described below, FormatFloatL will also apply any rules associated with the locale of the computer running RTMC Pro.
Syntax
String = FormatFloat ( value, format )
String = FormatFloatL ( value, format )
Remarks
The value parameter is the variable or constant that holds the floating point value to be converted. The format determines how the floating point value will be represented in the converted string. Note that in most cases the format will be a literal string and, therefore, must be enclosed in quotes and preceded by a $. The options are (m = mantissa; d = decimal; x = exponent):
Code Description
%f Decimal notation in the form of +mmm.dddddd; precision is 6 places to the right of the decimal.
%e (or %E) Decimal notation in the form of +m.dddddd e+xx; precision is 6 places to the right of the decimal.
%g (or %G) Mantissa and decimal are variable; trailing 0s and decimals are omitted.
%Y.Zf Decimal notation in the form of +m.d; total field width is defined by Y . Precision is defined by Z.
%0Y.0Zf Decimal notation in the form of +m.d; total field width is defined by Y . The mantissa will be padded by leading 0s if necessary. Precision is defined by Z. The decimal will be padded with trailing 0s.
%Ye (or %YE) Decimal notation in the form of +m.d e+xx; total field width is defined by Y.
%Yg (or %YG) Mantissa and decimal are variable; total field width is defined Y.
NOTE: Total field width includes decimal point and sign.
NOTE: Other ASCII characters can be included in the FormatString (e.g., FormatFloat(Variable,$"The current reading is %2.3G").