this is a better base conversion algorithm:

check out the method of complementsCode:std::valarray<unsigned int> baseConvert(unsigned int value,unsigned int base) { unsigned int digits = 1+log((double)value)/log((double)base); std::valarray<unsigned int>result(digits); for(int i=0;i<digits-1;i++) { result[i]=value%base; value/=base; } result[digits-1]=value; return result; }