It is not clear whether 'subtraction' operation for given base B1 is granted
defined or you should write code for it. If it is already defined, then
simulating division (working wrt base B1) is easy (repeated subtraction).
Then the normal procedure of converting a number from base 10 to base b2
would work, where you divide the number by B2, note down the remainder,
replace dividend by the quotient and repeat the process until the dividend
becomes zero. Finally you concatenate the remainders in the reverse order.

Ex: From 214 of base 5 to base 16.
16 is 31 of base 5 so,
214 / 31 =* **3* ;  214 % 31 = "21";  [ / and % work wrt base 5 which is to
be programmed using repeated subtraction ]
*3* / 31 = 0 ;   3 % 31 = "3";

finally
"3,21"
or
"3B" coz  B is hex equivalent of 21_base5

OR
in your simpler algo, is it not possible to define functions that 'get' and
'set' a particular digit, by using / and % ?
Thanks,
Summ

On Tue, Aug 17, 2010 at 9:50 PM, luckyzoner <luckyzo...@gmail.com> wrote:

> I had proposed an algorithm of repeatedly subtracting 1 from the given
> number and subsequently adding 1 to the new number initialised to 0,
> till the given number becomes 0. However as soon as the digit reaches
> the limit , the digit becomes 0 and you add 1 to the next digit. I was
> not able to code it properly as i had to use int data type only. It
> would have been easy if the array of integers was allowed to use.
>
> Pls suggest the code for the same or some better algo.
>
> Thanx
> Lakshaya
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to