我一直用这个,思路清晰,位数扩展容易,对一般的应用足够了:
//int32到ASCII码的转换
void int32_to_ascii(int32 counter, int8 * asc8) {
const int32 c[8]={10000000,1000000,100000,10000,1000,100,10,1};
int8 i;
int16 k;
for(i=0;i<8;i++){
k=0;
while(counter>=c[i]){
counter-=c[i];
++k;
}
asc8[i]= k+0x30;
}
} |