Can you believe I can't figure it out? And can you believe that I've never had to do this before? =).

Anyway, what I need to do is convert an integer of a file's size from bytes to kbytes and mbytes etc.

So say something is 1024 bytes, I know that's a kbyte, but what process / math do I have to use to work it all the way up to terabytes without loosing integrity in the numbers.

Both to and from conversions would be useful.

Thanks in advance. =).