Here's my new bytecalc() function for PB 4.01+. (Don't try to beat this, the german-forum-competition is over

This procedure turns a quad number of bytes into the greatest unit.
Eample:
1024 Byte => 1 KB
16777216 => 16 MB.
You can optionally switch on decimals numbers; the procedure automatically enforces no decimal numbers, if the greatest unit is "Byte", because it doesn't make sense to have 3.67 Byte, does it?

Code: Select all
Procedure.s bytecalc(byte.q, NbDecimals.b=0)
Protected unit.b=Round(Log(byte)/Log(1024), 0)
ProcedureReturn StrD(byte/Pow(1024, unit), NbDecimals*(unit And 1))+" "+StringField("Byte,KB,MB,GB,TB,PB,EB", unit+1, ",")
EndProcedure
Debug bytecalc(FileSize("C:\pagefile.sys"))
Debug bytecalc(3.67*1024)
Debug bytecalc($FFFFFF)
Debug bytecalc(1024)
