decimal to given base

//This function can be used to convert decimal to given base
void To(long long num,char *buff,int base)
if(buff==NULL) return;
long long m=0,no=num,i=1;

while((no/=base)>0) i++;

buff[--i]=(m>9)?((base==16)?('A' + m - 10):m):m+48;
what is the problem ?
It doesn't handle negative numbers, or zero.

A value of base greater than 10, such as base==12 gives results which are not readable. That's because the character output when base is greater than 10 but not equal to 16 is just m. It might be better to use 'A' + m - 10 for any value of base which is greater than 10.
Topic archived. No new replies allowed.