Utilities.FormatFloat Method

Applies to TestComplete 14.40, last modified on April 22, 2021
This method is obsolete. See the Remarks section below.

Description

Use the Utilities.FormatFloat method to convert the specified floating-point value to a string using the format specified by the Format parameter.

Declaration

Utilities.FormatFloat(FormatValue)

Format [in]    Required    String    
Value [in]    Required    Double    
Result String

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

Format

Specifies the format to be used for conversion. Format is a string that may include up to three sections separated by semicolons. The first section specifies the format for positive values, the second - for negative values and the third - for zero. The second and third sections can be empty. In this case, the function will use the positive number format for conversion of negative values and zeros. If the first section is empty or the entire format string is empty, FormatFloat converts the Value using the general number format (that is, a call to FormatFloat corresponds to a call to FloatToStrF with the ffGeneral format specifier).

Each section may hold the following format specifiers:

Specifier Description
0 If the converted number has digit in the position where 0 is specified in the format string, then this digits is copied to the resulting string. Otherwise, 0 is copied.
# Similar to the 0 specifier. The difference is that if the value has no digit in the position where # is specified in the format string, nothing is copied to the resulting string.
. Specifies the position of the decimal point. If the formatting string includes several decimal point specifiers, all of them are ignored except for the first one. The character that is used as a decimal separator is specified by the DecimalSeparator property.
, Specifies that the resulting string will include thousand separators. The number and position of thousand separator specifiers in the formatting string has no effect on the resulting string. The character that is used as the thousand separator is specified by the ThousandSeparator property.
E+, E-, e+ or e- Specifies that the resulting string will represent the Value using the scientific format. The 0 specifiers that immediately follow E+, E-, e+ or e- specify the number of digits for the exponent. The maximum number of 0s in this group is 4. If you use E+ or e+, the exponent will always have the sign. If you use the E- or e- specifiers, the sign will be displayed only for negative exponents.
'abc' or "abc" Characters enclosed in single or double quotes have no effect on the formatting. They are just copied to the resulting string.

Value

Specifies the floating-point value to be converted to a string.

Result Value

The specified floating-point value converted to a string.

Remarks

This method is obsolete. It is supported for backward compatibility only. To convert a floating-point value to a string in a specific format, use the aqString.Format method.

When converting, the Value is always rounded to as many digits after the decimal point as there are 0 or # specifiers after the decimal point in the formatting string. If the formatting string does not hold the decimal point specifier, the Value is rounded to the nearest whole number.

See Also

Working With Numeric Values
Format Method
FloatToStr Method

Highlight search results