I need some help to do number conversion...:
I got a 9 digit integer from another function (say int A = 123456789)
and need to make a 4 digit one (int B, say 6789) from A. Then I send B
to user.
User types in 4 digit integer (int C) and I check whether B == C. If
true, then I convert B to back to A again.
So how can I convert A to B and then B to A? Any algorithm I can use,
say get the last four digit of A?
Lee Weiner - 28 Jul 2006 02:47 GMT
>I need some help to do number conversion...:
>
[quoted text clipped - 7 lines]
>So how can I convert A to B and then B to A? Any algorithm I can use,
>say get the last four digit of A?
Mod A with 10000:
int B = A % 10000;
Why do you have to convert B back to A? Don't you still have the value of A
stored in a variable? It's still there.
Lee Weiner
lee AT leeweiner DOT org
usgog@yahoo.com - 28 Jul 2006 03:17 GMT
You are correct...Thanks!
> >I need some help to do number conversion...:
> >
[quoted text clipped - 17 lines]
> Lee Weiner
> lee AT leeweiner DOT org