fork(2) download
  1. procedure humanize(size: QWord);
  2. var
  3. c: char;
  4. begin
  5. for c in 'BKMGT' do
  6. begin
  7. if (size shr 10 = 0) or (c = 'T') then break;
  8. size := size shr 10;
  9. end;
  10. Writeln(size, c);
  11. end;
  12.  
  13. begin
  14. humanize(42);
  15. humanize(1024 * 1024);
  16. humanize(8192);
  17. humanize(QWord (1073741824) * 4);
  18. humanize(High(QWord));
  19. end.
  20.  
Success #stdin #stdout 0s 4144KB
stdin
Standard input is empty
stdout
42B
1M
8K
4G
16777215T