# Thread: Base conversion

1. Senior Member
Join Date
Mar 2013
Posts
123
Rep Power
0

## Base conversion

Hello forum. I am confused. I am writing a method that takes in a int value and a base and from those two find the base number . For example: The method takes a number, say 342, and converts it to a base (any base).

I understand the algorithm, cant fathom the code

Heres what I know

value % base = first digit starting from right
(value/base) % base = second digit starting from the right
(value/base^2)% base = third digit starting from right...

,... and so forth.

I am not sure how to write this loop. I was thinking a while...I cant see this. Can some one help me better understand how to loop this? THanks in advance

2. Senior Member
Join Date
Jan 2013
Location
United States
Posts
2,734
Rep Power
4

## Re: Base conversion

Get some paper and pencil and go through the algorithm by hand. You should notice a repetitive pattern. Also, do this when converting decimal to decimal. It might make it easier to visualize.

Regards,
Jim

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•