Table of Contents

Corning Community College

CSCS2330 Discrete Structures

Project: NUMBER BASE MANIPULATIONS (nbm0)

Objective

To apply your skills in crafting and deploying an algorithm that will enable you to convert a value from a source base to a destination base.

number bases

Number representation, as we first learned it, revealed a beautiful system of places with various weight values. Each place can increment or decrement its available counting digits until we reach either end of our range, then we “roll over”. In the case of addition, our highest counting digit rolls over to our lowest one, and we carry a one over to the next highest weighted place value.

What counting values are available depend on the numeric base we are operating within; base 10 (decimal) gives us ten unique counting digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

Base 5 gives us five unique counting digits: 0, 1, 2, 3, 4.

Base 12 gives us twelve unique counting digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B.

The standard convention used once we exceed base 10 is to start utilizing the letters of the alphabet.

In this manner, we can easily interact with bases 2-36 (10 number digits, 26 alphabet letters, 10+26 = 36); we omit the non-sensical bases of 0 and 1 as a matter of course.

Converting between bases, we need to preserve the stored value, while adapting it to the new quantity of counting digits.

Program

Your task is to write a program that:

Restrictions

Additional constraints:

Sample Output

Sample output is as follows:

Convert from base 8 to base 10

lab46:~/src/discrete/nbm0$ ./nbm0 8 31 10
25
lab46:~/src/discrete/nbm0$ 

Convert from base 9 to base 3

lab46:~/src/discrete/nbm0$ ./nbm0 9 8843 3
22221110
lab46:~/src/discrete/nbm0$ 

Convert from base 2 to base 16

lab46:~/src/discrete/nbm0$ ./nbm0 2 11010001 16
D1
lab46:~/src/discrete/nbm0$ 

Submission

Submission

To successfully complete this project, the following criteria must be met:

To submit this program to me using the Makefile tool (make submit), run the following:

lab46:~/src/discrete/nbm0$ make submit
removed ‘nbm0’
removed ‘errors’

Project backup process commencing

Taking snapshot of current project (nbm0)      ... OK
Compressing snapshot of nbm0 project archive   ... OK
Setting secure permissions on nbm0 archive     ... OK

Project backup process complete

Submitting discrete project "nbm0":
    -> ../nbm0-YYYYMMDD-HH.tar.gz(OK)

SUCCESSFULLY SUBMITTED
lab46:~/src/discrete/nbm0$ 

You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.

Evaluation Criteria

What I will be looking for:

104:nbm0:final tally of results (104/104)
*:nbm0:submitted file called nbm0.c [5/5]
*:nbm0:adequate indentation [8/8]
*:nbm0:sufficient comments [8/8]
*:nbm0:adequate error checking [13/13]
*:nbm0:adequate modifications [13/13]
*:nbm0:commit and pushed to repo [5/5]
*:nbm0:clean compilation [13/13]
*:nbm0:runtime tests succeed [39/39]

Additionally: