StrF()

语法

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

参数

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'.

返回值

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().

示例

  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

参阅

StrD(), Str(), StrU()

已支持操作系统

所有

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