StrF()

Syntax

Result$ = StrF(Value.f [, NbDecimal])
Description
Converts a float number into a string.

Parameters

Value.f The value to convert.
NbDecimal (optional) The maximum number of decimal places for the converted number. If omitted, it will be set to 10 decimal places, with removing the trailing zeros. The number will be rounded, if 'NbDecimal' is smaller than existing decimal places of 'Value.f'.

Return value

A string holding the converted value.

Remarks

Signed integer numbers have to be converted with Str() and unsigned numbers with StrU(). It is possible to omit this command when concatenating string and float, it will then use the default behaviour of StrF().

Example

  value.f = 10.54
  Debug "Result: " + StrF(value)    ; we do not use the 2nd parameter, so we get a float number rounded to 10 decimal places
  Debug "Result: " + value          ; same as previous line
  Debug "Result: " + StrF(value,2)  ; we want a result with two decimal places, no rounding needed as we have only two
  Debug "Result: " + StrF(value,0)  ; we want a result with no decimal places, so the value is rounded

See Also

StrD(), Str(), StrU(), FormatNumber()

Supported OS

All

<- StrD() - String Index - StrU() ->