CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Convert Q.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
opl3
Guest







Convert Q.
PostPosted: Sun Dec 19, 2004 10:09 am     Reply with quote

Please answ. me how convert
int32 = 123456789 to int32 = 987654321
Ttelmah
Guest







Re: Convert Q.
PostPosted: Sun Dec 19, 2004 11:23 am     Reply with quote

opl3 wrote:
Please answ. me how convert
int32 = 123456789 to int32 = 987654321

You would have to dismantle the value into digits (divide by 10, and take the remainder) repeatedly, then put the digits back together in the opposite order. You could use the string functions to do this. It is a relative 'lot' of work, whichever approach is used.
I have to ask 'why'?. If this is for output, then print the number to a string, and then output the string digits in reverse order, would be easier than reversing the number itself.

Best Wishes
opl3
Guest







PostPosted: Sun Dec 19, 2004 12:10 pm     Reply with quote

I don't need use printf in my program
So thanks I must "divide by 10, and take the remainder"

Thanks a lot !
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Dec 19, 2004 4:08 pm     Reply with quote

32-bit div and multiply will do the job but requires a lot of code space.

We might be able to give you better solutions when you describe your problem in more detail.

For example, coding the number as a BCD value might be an option and this can be efficiently ordered any way you want to.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group