Base Convertion

..
Last edited on
I know this sounds awkward, but what exactly don't you know?

To output text you can use printf().
To input data you can use scanf().
These are found in stdio.h: http://www.cplusplus.com/reference/clibrary/cstdio/

Division and modulus operations: / and %.

How to apply them: http://rachel5nj.tripod.com/NOTC/convertingbases.html
(out of the many sites)

Try, and return when you have a specific problem.
hi,
this is the formula:
logb(x) = logk(x) / logk(b)
where:
b = base
x = number
k = any base, tipicaly 10 or 2.718...

you can find log function in math.h
then write a function which will convert base with that formula for number x.


..
Last edited on
When I convert to hexadecimal base, how do I make it so the 10's are displayed as "A", 11's as "B", and so forth?
cout << hex;
for example:
1
2
int var = 0xff;
cout << hex << var;


to get decimal back use:
cout << dec;
...
Last edited on
Two questions:
1) Is x set to zero before the while(Dec!=0) at line 8?
2) How big is the rem[] array? How many values can it store?
...
Last edited on
number with more than 3 digits


Example: 354410 = 1101110110002.
You would need to store 12 elements.
The rem[10] array is not big enough to store your data.

Easy solution: make rem[] bigger.
Last edited on
..
Last edited on
Topic archived. No new replies allowed.