Name

String::FormatSizeWithPrecision — Return a pretty description of a byte count

Synopsis

Import String;
string String::FormatSizeWithPrecision ( integer  bytes ,
  integer  precision ,
  boolean  omit_zeroes );

Parameters

integer bytes

size (e.g. free diskspace, memory size) in Bytes

integer precision

number of fraction digits in output

boolean omit_zeroes

if true then do not add zeroes (usefull for memory size - 128 MB RAM looks better than 128.00 MB RAM)

Return Value

string

formatted string

Description

Return a pretty description of a byte count with required precision and using KB, MB or GB as unit as appropriate.

Examples

  FormatSizeWithPrecision(4096, 2, true) -> "4 KB"
  FormatSizeWithPrecision(4096, 2, false) -> "4.00 KB"