View previous topic :: View next topic |
Author |
Message |
opl3 Guest
|
Convert Q. |
Posted: Sun Dec 19, 2004 10:09 am |
|
|
Please answ. me how convert
int32 = 123456789 to int32 = 987654321 |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
Re: Convert Q. |
Posted: Sun Dec 19, 2004 11:23 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
opl3 Guest
|
|
Posted: Sun Dec 19, 2004 12:10 pm |
|
|
I don't need use printf in my program
So thanks I must "divide by 10, and take the remainder"
Thanks a lot ! |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Dec 19, 2004 4:08 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
|