Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/23/05 08:42
Read: times


 
#101428 - Keil C51-optimization & Pointers
Responding to: ???'s previous message
Hi Vignesh

To Convert number to a string the following function seems to be better than your function(i.e tostr). This will also saves your memory and increases the processing speed.

char* Convert_to_Str(unsigned int num)
{
unsigned int base;
unsigned char rem,x;
char buff[6];
char *ptr=buff;
if(num == 0)
{
*ptr = num + 0x30;
ptr++;
}
else
{
while(num)
{
rem = num/10;
num = num%10;
base =(base * 10) + rem + 0x30 ;
*ptr = base;
ptr++;
}
}
*ptr = '';

return buff;
}



List of 18 messages in thread
TopicAuthorDate
Keil C51-optimization & Pointers            01/01/70 00:00      
   Bad array index            01/01/70 00:00      
      oops!!            01/01/70 00:00      
         buff[] is auto, not static            01/01/70 00:00      
            Back to basics            01/01/70 00:00      
               Don't shoot the pianist!            01/01/70 00:00      
   Hex file size            01/01/70 00:00      
      Optimization pointers            01/01/70 00:00      
         sprintf() is fairly large            01/01/70 00:00      
         So start a new thread, then!            01/01/70 00:00      
         pls...help            01/01/70 00:00      
            I disagree            01/01/70 00:00      
      My dear Watson !            01/01/70 00:00      
         One size fits all            01/01/70 00:00      
   bin = hex / 2.8            01/01/70 00:00      
      hexmap            01/01/70 00:00      
      A bit of a sweeping generalisation!!            01/01/70 00:00      
   Keil C51-optimization & Pointers            01/01/70 00:00      

Back to Subject List