University of Calgary

decimal to any base converter

Decimal to any Base Converter
source: Katrin Becker, 1988
Write an interactive program to convert decimal integers to another base.
Program must handle all positive integers up to a reasonable range.
All target bases from 2 to at least 16 must be allowed.
The program must handle invalid input in a reasonable manner and must be user-friendly.
The program must allow the user to continue 'playing with it' until the user wishes to quit.
 
Testing:
Test your program on at least the following numbers:
 Target Base
numbers to convert
1
----

 17 [33 if doing to base 32]

 ----

 2
0,  1, 16,  65,535 65,535,  1,048,575,  1,048,576, 2,147,483,647, 2,147,483,648  {-7, -1, -15, -29}
10
-30, -7, -10, 0, 1, 10, 72, 1,048,576
 20
 1,000,000
BONUS:
1. include all target bases from 2 to 32
2. - include negative values
a) expresses as values with a preceding '-'
b) expressed as a compliment (must show absolute value as well)
3. show conversion process step by step
4. include numbers with a fractional part



Updated: August 30, 2005 05:09 PM