How do you convert from base-r to 10 to 6?

mOeeOm

Platinum Member
Dec 27, 2004
2,588
0
0
The code works fine now, but I need it to convert whatever the answer is to base 10 and then to base 6. How do you write this in C language? I know the math of it but can't put it in C language.

Any help would be appreciated.
 

mOeeOm

Platinum Member
Dec 27, 2004
2,588
0
0
Quotient Remainder Coefficient
129/8 = 16 1 1
16/8 = 2 0 0
2/8 = 0 2 2

129 from base 10 to base 8, how would you write this in C language for any number?
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
Didn't you learn how "%" works in the last assignment? does the number to the right of it have to always be a constant?

for base-r _to_ base-10 think about how you convert binary to decimal
 

mOeeOm

Platinum Member
Dec 27, 2004
2,588
0
0
Originally posted by: DaveSimmons
Didn't you learn how "%" works in the last assignment? does the number to the right of it have to always be a constant?

for base-r _to_ base-10 think about how you convert binary to decimal

Yes, I know you keep multiplying by the base, so if its (XYZ.W)r its = X x r^2 + Y x r^1 + Z x r^0 + W x r-1 and that gives me base 10, but I dont know how to write it in C language for any number and how to input it in the calculator program.