Welcome

首页 / 软件开发 / Delphi / Delphi格式化输出函数(3): FormatFloat

Delphi格式化输出函数(3): FormatFloat2011-04-23万一
var
s: string;
begin
//FormatFloat 的参数1是 String 格式指令, 参数2是实数类型 Extended
s := FormatFloat("###.###",12.3456);
//返回: 12.346
s := FormatFloat("000.000",12.3456);
//返回: 012.346
s := FormatFloat("#.###",12.3);
//返回: 12.3
s := FormatFloat("0.000",12.3);
//返回: 12.300
s := FormatFloat("#,#.#",1234567);
//返回: 1,234,567
s := FormatFloat("0,0.0",1234567);
//返回: 1,234,567.0
s := FormatFloat("0.00E+0",1234567);
//返回: 1.23E+6
s := FormatFloat("0.00E+00",1234567);
//返回: 1.23E+06
//在科学计数法中使用 # 好像不合适?
ShowMessage(s);
end;