C program to convert number to binary, C/C++ Programming

Write a program in C that you will name "divide.exe", to divide one 32-bit twos-complement binary number by another, giving the quotient and the remainder, using the subtract-shift division algorithm as demonstrated in class.

The program will be called using: div32 , where and are given as strings of up to 31 1's and 0's, with an optional sign. Your program must check that the input numbers are reasonable. The result must be output as binary numbers. Here are some example inputs and outputs:

> divide 1101011 1001

1101011 divided by 1001 is 1011 remainder 1000

> divide 107 9

107 is not a binary number

> divide -101001101 1100

101001101 divided by -1100 is -11011 remainder 1001

> divide 100010001000100010001000100010001 11101 0

100010001000100010001000100010001 is out of range

The exact error messages that need to be displayed are left to the discretion of the programmer. The inputs must be read in as text strings, and parsed and converted to appropriate long integers by your program. Similarly, the quotient and remainder must be converted and output as a sequence of 1's and 0's by your program.

Describe any limitations that may exist for your program. Full marks will only be given to programs capable of handling the complete range of inputs, however, a proper explanation of any limitations your program may have will minimize any deductions. Only properly commented code will receive full marks.

To test your code, select appropriate test cases to show that it works throughout the possible input range. Choosing a test set is a non-trivial problem and should be done with care, concentrating on number boundaries (maximum, minimum) and other code specific areas which may result in problems for your code. Include a printout of the results for all of your tests.

HINT: You may want to first implement an 8-bit version of your program, using signed chars rather than signed longs, and write a test program which checks it for all possible inputs. Once you are sure it works, you can convert it to the 32-bit version.

The "C" source code should contain a header which has the following information:

1.       Full name

2.       Student number

3.       Course number

4.       Date

Posted Date: 3/1/2013 12:39:44 AM | Location : United States







Related Discussions:- C program to convert number to binary, Assignment Help, Ask Question on C program to convert number to binary, Get Answer, Expert's Help, C program to convert number to binary Discussions

Write discussion on C program to convert number to binary
Your posts are moderated
Related Questions
Implement a Algorithm to verify if the link list is in Ascending order? A: template bool linklist::isAscending() const{ nodeptr ptr = head; while (ptr->_next)

Design a game in c: const DODGERS = 0; const GIANTS = 1;   void main(void) {    int scoreboard [2][9];    // An array two rows by nine columns    int team, i


C Program for SORTING OF LONG WORD WITH DIFFERENT STRING #include stdio.h> #include conio.h> #include string.h>   void main() {           char n[50],c[25][25]

Consider text comprised of sentences and sentences comprised of words. Words in a sentence will be space delimited. Given a text and K strings, task is to find out the number valid

write a program to calculate the cuboid

evolutio of object oriented programing

Structures A structure is a user-defined data type, which may have different data types as its members. Creating a structure is a two-part process. First, a structure template


Project Description: I have a code that works different on 64 bit and 32 bit system. Code is relative to some crypt functions, similar, but not equal to: I have to move fr