Format file size for printing

A

abcd

is there a built-in way of printing the size of a file nicely?

So if the file size is 103803 bytes it prints out like: 103.8K
or
0.1MB

something liek that?
 
J

John Zenger

I know of no built-in way, but you could probably code this in a few
lines using print "%.1f" and so on.

(Some of us, by the way, are in the camp that believes a kilobyte is
1024 bytes, not 1000, so 103803 bytes for us is about 101.4 kilobytes).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top