diff --git a/source/const.inc b/source/const.inc index 1fbfd040..146c6ab7 100644 --- a/source/const.inc +++ b/source/const.inc @@ -56,6 +56,14 @@ const {Pebibyte} SIZE_PB = 1125899906842624; {Exbibyte} SIZE_EB = 1152921504606846976; + // Size of byte units for formatting purposes + {Kibibyte} FSIZE_KB = 1000; + {Mebibyte} FSIZE_MB = 1024000; + {Gibibyte} FSIZE_GB = 1048576000; + {Tebibyte} FSIZE_TB = 1073741824000; + {Pebibyte} FSIZE_PB = 1099511627776000; + {Exbibyte} FSIZE_EB = 1125899906842624000; + // Abbreviations of byte unit names {Bytes} NAME_BYTES = ' B'; {Kibibyte} NAME_KB = ' KiB'; diff --git a/source/helpers.pas b/source/helpers.pas index 92a8aad4..14f45c9f 100644 --- a/source/helpers.pas +++ b/source/helpers.pas @@ -1014,15 +1014,15 @@ end; } function FormatByteNumber( Bytes: Int64; Decimals: Byte = 1 ): String; Overload; begin - if Bytes >= SIZE_PB then + if Bytes >= FSIZE_PB then Result := FormatNumber( Bytes / SIZE_PB, Decimals ) + NAME_PB - else if Bytes >= SIZE_TB then + else if Bytes >= FSIZE_TB then Result := FormatNumber( Bytes / SIZE_TB, Decimals ) + NAME_TB - else if Bytes >= SIZE_GB then + else if Bytes >= FSIZE_GB then Result := FormatNumber( Bytes / SIZE_GB, Decimals ) + NAME_GB - else if Bytes >= SIZE_MB then + else if Bytes >= FSIZE_MB then Result := FormatNumber( Bytes / SIZE_MB, Decimals ) + NAME_MB - else if Bytes >= SIZE_KB then + else if Bytes >= FSIZE_KB then Result := FormatNumber( Bytes / SIZE_KB, Decimals ) + NAME_KB else Result := FormatNumber( Bytes ) + NAME_BYTES