Simple Conversion from Bytes to Kilobytes, Megabytes, Gigabytes and reverse

Posted: June 15, 2009 in Programming Tips
Tags: ,

Upconversion

FileSize_KB = FileSize_Byte >> 10;
FileSize_MB = FileSize_Byte >> 20
FileSize_GB = FileSize_Byte >> 30;

Down Conversion

FileSize_Byte = FileSize_KB << 10;
FileSize_Byte = FileSize_MB << 20;
FileSize_Byte = FileSize_GB << 30;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s