Base Convertion

Nov 21, 2011 at 7:14pm
..
Last edited on Dec 8, 2011 at 1:44pm
Nov 21, 2011 at 7:40pm
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.
Nov 21, 2011 at 7:45pm
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.


Nov 21, 2011 at 9:59pm
..
Last edited on Dec 8, 2011 at 1:44pm
Nov 26, 2011 at 7:36pm
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?
Nov 26, 2011 at 10:30pm
cout << hex;
for example:
1
2
int var = 0xff;
cout << hex << var;


to get decimal back use:
cout << dec;
Nov 30, 2011 at 9:47pm
...
Last edited on Dec 8, 2011 at 1:44pm
Nov 30, 2011 at 11:25pm
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?
Dec 1, 2011 at 1:10am
...
Last edited on Dec 8, 2011 at 1:44pm
Dec 1, 2011 at 1:44am
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 Dec 1, 2011 at 1:46am
Dec 1, 2011 at 3:32am
..
Last edited on Dec 8, 2011 at 1:44pm
Topic archived. No new replies allowed.