本文整理自网络,侵删。
//整型
function TForm1.IFormatByte(nSize: Int64): string;
begin
if nSize > 1073741824 then
Result := FormatFloat('###,##0.00G', nSize / 1073741824)
else if nSize > 1048576 then
Result := FormatFloat('###,##0.00M', nSize / 1048576)
else if nSize > 1024 then
Result := FormatFloat('###,##00K', nSize / 1024)
else
Result := FormatFloat('###,#0B', nSize);
if Length(Result) > 2 then
if Result[1] = '0' then
Delete(Result, 1, 1);
end;
function TForm1.FFormatByte(fSize: Double): string;
begin
if fSize > 1073741824.0 then
Result := FormatFloat('###,##0.00G', fSize / 1073741824.0)
else if fSize > 1048576.0 then
Result := FormatFloat('###,##0.00M', fSize / 1048576.0)
else if fSize > 1024.0 then
//Result := FormatFloat('###,##00K', fSize / 1024.0)
Result := FormatFloat('###,##00.00K', fSize / 1024.0)
else
Result := FormatFloat('###,#0B', fSize);
if Length(Result) > 2 then
if Result[1] = '0' then
Delete(Result, 1, 1);
end;
相关阅读 >>
Delphi 的 tstringbuilder 可以完美实现jave ,c#的tstringbuilder功能
Delphi xe android的所有权限按照分类总结说明
Delphi firedac 如何按整型(byte)读取 mysql tinyint(1) 类型字段?
Delphi idmessage1 idsmtp1 发送邮件支持https
Delphi windows 编程[5] - 学习窗体生成的过程五
更多相关阅读请进入《Delphi》频道 >>