Einzelnen Beitrag anzeigen

Benutzerbild von jaenicke
jaenicke

Registriert seit: 10. Jun 2003
Ort: Berlin
9.351 Beiträge
 
Delphi 11 Alexandria
 
#7

AW: Byte --> Kb/Mb/Gb

  Alt 9. Aug 2013, 05:30
Also ich mache das einfach so...
Delphi-Quellcode:
function FormatDiskSpaceSize(const ASize: Int64): string;
const
  cBinaryPrefixes: array[0..8] of String = ('', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi');
var
  LogValue: Integer;
begin
  LogValue := Floor(Math.LogN(1024, ASize));
  Result := FloatToStrF(ASize / Math.Power(1024, LogValue), ffFixed, 12, 2) + ' ' + cBinaryPrefixes[LogValue] + 'B';
end;
// EDIT:
Quasi, weil es imho von nahezu allen Standardisierungsorganisationen so anerkannt wird, aber eine formelle Norm gibt es glaube ich nicht.
Doch gibt es:
IEC 80000-13:2008
Sebastian Jänicke
Alle eigenen Projekte sind eingestellt, ebenso meine Homepage, Downloadlinks usw. im Forum bleiben aktiv!

Geändert von jaenicke ( 9. Aug 2013 um 05:33 Uhr)
  Mit Zitat antworten Zitat