Documentation
Back to website >

FormatFloat (Pascalscript)

Description

FormatFloat formats a floating point value.

Syntax

function FormatFloat(const Format: string; Value: Extended): string;

Arguments

FormatFloat formats the floating point value specified with Value. The format string passed in the Format parameter is used for this. An overview of the possibilities of format can be found here.

Example

var
  S : String;
  e : Extended;
begin
  e:=4563.2;
  S:=FormatFloat('###,##0.00',e);
  ShowMessage(s);
end;

Rules to understand the script can be found here.

The value 4563.2 is assigned to the floating point variable e. The FormatFloat function converts this numerical value into a formatted text and assigns it to the variable S.

ShowMessage shows: 4,563.20

A maximum display of 999,999.99 was specified in the format mask. A total of 2 decimal places are rounded. If there are fewer decimal places, they are filled with 0. If the number is smaller than 0, at least one leading 0 is output. If the number is greater than 999.99, it is formatted with thousands separations.

Note that a dot must be entered in the script instead of a comma, since the representation in the script is always international. The same applies to the format mask.