Last active
February 13, 2017 08:23
-
-
Save Delamare2112/9ec36b7f3e935e172393c5ea63c133f8 to your computer and use it in GitHub Desktop.
This file contains 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
std::string itoawb(size_t val, size_t base) | |
{ | |
if(val == 0) | |
return "0"; | |
size_t buffSize = (size_t)(log2(val) + 1); | |
std::string ret(buffSize, 0); | |
buffSize *= 1.25; | |
buffSize++; | |
size_t i = buffSize-1; | |
for(;val && i; --i, val /= base) | |
{ | |
ret[i] = "0123456789abcdefghijklmnopqrstuvwxyz"[val % base]; | |
} | |
int j = 0; | |
i++; | |
for(; i < buffSize; i++, j++) | |
ret[j] = ret[i]; | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment