Is there a way (without encoding explicitly) to display a number using metric prefixes?

This question is related to This question , using some functions of Windows Explorer automatically inside a Delphi application.

Is there a way to format an integer using metrix prefixes automatically in Delphi? Somehow automatically get the result, as Windows Explorer gives? I mean converting 1024 to 1.0 K automatically.

let's say something like

FormatMetric('FileSize = %d', [26112], 1,'B')
// where the third parameter is the number of decimal digits
// and the fourth is the string that is appended

will return

25.5 KB

Of course I can encode this, but is there something like this in RTL?

+3
source share
1 answer

You need a call to the Windows API StrFormatByteSizeA.

. msdn: http://msdn.microsoft.com/en-us/library/bb759974%28VS.85%29.aspx

+6

Source: https://habr.com/ru/post/1747170/


All Articles