FormatFloat

Converts a floating-point value to a string and specifies the format.

Syntax

FormatFloat(format, number)
format = string specifying the format to apply to the number.
number = number to be formatted

Remarks

The format string must contain a numerical indicator, such as:

  • %[.[0]prec]f for single-precision floating-point formatting;
  • %[.[0]prec]e for exponential formatting;
  • %[.[0]prec]n for floating-point formatting using the thousand separator.

The optional precision attribute prec is used to indicate the number of decimal places to display. If prec is preceded by a zero, zeros will be used to fill out the specified number of decimal places.

To include the "%" symbol in your formatting string, you will need to input it twice: "%%".

If the string starts with a "¤", the number will be understood as a date value, and the rest of the formatting string will be understood as per the specifications for FormatDateTime.

Starting with Qubes 6.5, dynamic formatting strings will be supported for %f and ''%e'. For earlier versions and other formats, the formatting string is treated as static.

Examples

FormatFloat('%.2f', pi) = "3.14"
FormatFloat('%.0f', pi) = "3"
FormatFloat('%.03f%%', 5) = "5.000%"
FormatFloat('%.2n µ', pi*10000) = "31 415.93 µ"

Classification

Maths Strings