-
-
Save IMRANALI149/07b6567cd0790ba92963ba822dabb3c2 to your computer and use it in GitHub Desktop.
Humanizing bytesize in C/C++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string hByte(unsigned int bytes){ | |
string r; | |
if (bytes <= 0) r = "0 Bytes"; | |
else if (bytes >= 1073741824) r = to_string(bytes/1073741824) + " GBytes"; | |
else if (bytes >= 1048576) r = to_string(bytes/1048576) + " MBytes"; | |
else if (bytes >= 1024) r = to_string(bytes/1024) + " KBytes"; | |
return r; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment