Created
April 24, 2010 14:00
-
-
Save nesium/377674 to your computer and use it in GitHub Desktop.
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
static uint64_t count = 7; | |
static NSString *suffixes[7] = {@"B", @"KiB", @"MiB", @"GiB", @"TiB", @"PiB", @"EiB"}; | |
uint64_t i, c; | |
for (i = 1024, c = 0; i < (count << 60); i <<= 10, c++){ | |
if (bytes < i) | |
return [NSString stringWithFormat:@"%0.2f%@", | |
(double)bytes / (double)(i >> 10), suffixes[c]]; | |
} | |
return @"Big"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment