Re: [algogeeks] Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base

2010-09-08 Thread Patidarchat Gmal
i guess the problem is just told in different format observe careful it is converting a number into the given base(limit given). -- Thanks & Regards Rajesh Patidar On 17-08-2010 21:50, luckyzoner wrote: I had proposed an algorithm of repeatedly subtracting 1 from the given number and subsequ

Re: [algogeeks] Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base

2010-08-19 Thread Terence
Do all calculations in base B2. All you need is the addition and multiplication in base B2 (add_b2() and mul_b2()). Then simply calculate An*B1^n+An-1*B1^(n-1)+...+A1*B1+A0 (X=AnAn-1...A1A0 in base B1) in base B2. For add_b2() and mul_b2(), if you have done high precision addition/multipli

Re: [algogeeks] Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base

2010-08-18 Thread Rahul Singhal
Hi example (83)base 5 --> ()base7 num temp_num resultcarry 83 3* 1 (3/7) =0(3%7)=3 838*5 (40/7)=5 (40%7)=5 result=0+5=5 carry= 3+5=8 temp_carry=call convert for carry in which base is 10 and

Re: [algogeeks] Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base

2010-08-18 Thread sumant hegde
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 wou

Re: [algogeeks] Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base

2010-08-18 Thread Rais Khan
Below formula seems working to me for converting number from base B1 to base B2. But For intermediate operation we have to be careful, as comiler does all operation with base 10. newNum = (oldNum/newBase)*oldBase + oldNum%newBase; So Algo, 1. Number, oldBase, newbase; 2. First convert number from

[algogeeks] Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base

2010-08-17 Thread luckyzoner
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 i