mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Add support for TeraByte and PetaByte in FormatByteNumber.
Overcomes a "E2099 Overflow in conversion or arithmetic operation" compiler error by using constants instead of calculating the limits.
This commit is contained in:
@ -1956,12 +1956,20 @@ end;
|
||||
}
|
||||
function FormatByteNumber( Bytes: Int64; Decimals: Byte = 1 ): String; Overload;
|
||||
const
|
||||
KB = 1024;
|
||||
{KiloByte} KB = 1024;
|
||||
{MegaByte} MB = 1048576;
|
||||
{GigaByte} GB = 1073741824;
|
||||
{TeraByte} TB = 1099511627776;
|
||||
{PetaByte} PB = 1125899906842624;
|
||||
begin
|
||||
if Bytes >= KB *KB *KB then
|
||||
Result := FormatNumber( Bytes / (KB *KB *KB), Decimals ) + ' GB'
|
||||
else if Bytes >= KB *KB then
|
||||
Result := FormatNumber( Bytes / (KB *KB), Decimals ) + ' MB'
|
||||
if Bytes >= PB then
|
||||
Result := FormatNumber( Bytes / PB, Decimals ) + ' PB'
|
||||
else if Bytes >= TB then
|
||||
Result := FormatNumber( Bytes / TB, Decimals ) + ' TB'
|
||||
else if Bytes >= GB then
|
||||
Result := FormatNumber( Bytes / GB, Decimals ) + ' GB'
|
||||
else if Bytes >= MB then
|
||||
Result := FormatNumber( Bytes / MB, Decimals ) + ' MB'
|
||||
else if Bytes >= KB then
|
||||
Result := FormatNumber( Bytes / KB, Decimals ) + ' KB'
|
||||
else
|
||||
|
Reference in New Issue
Block a user