I wrote this code to convert from number in denary to a different base
I was curious if anyone has any tips on a better way to write this code
I'm always looking to improve my coding and I find others critiques to be a great way of improving.
In the below code I omit include's and presume the base isn't going to be above a certain number
string convertedNumber(long numberToConvert, int base)
{
char letterArray[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<short>baseNum;
while(numberToConvert != 0)
{
baseNum.push_back(numberToConvert % base);
numberToConvert = numberToConvert / base;
}
string convertedNum = "";
for(int i = baseNum.size()-1 ; i>=0; i--)
{
//This is presuming that the base is lower than 36
if(baseNum.at(i) > 9)
{
convertedNum += letterArray[baseNum.at(i)-10];
}
else
{
convertedNum += ((char)(baseNum.at(i) + '0'));
}
}
return convertedNum;
}