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

Assignment Help:

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


Related Discussions:- C program to convert number to binary

Area under a curve, Write a program to find the area under the curve y = f(...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

However shouldn''t i always use a printon() method instead , Q: however sho...

Q: however shouldn't I always use a printOn() method instead of a friend function? A: No. The usual cause people wish to always use a printOn() method instead of  a friend fu

Luminous jewels polishing necklace, 1.jewels can only be removed for polish...

1.jewels can only be removed for polishing from either end of the necklace. 2.cost of polishing=sitting number*colour value of jewels.

Hw8, Asks the user for an integer. if the number is less than 21, ask them ...

Asks the user for an integer. if the number is less than 21, ask them for a number again; repeat this until you get a number bigger than 20. 20 is not an acceptable number. Once yo

Matlab assignmnet, I have a Matlab assignment and I have the assignment des...

I have a Matlab assignment and I have the assignment description+ algorithm + and the output sample. the files are on a dropbox folder and you can download them from the link below

Is probable to encompass virtual constructor? if yes, Is it probable to enc...

Is it probable to encompass Virtual Constructor? If yes, how? If not, Why?

How do i develop a subscript operator for a matrix class?, Employ operator ...

Employ operator () instead of operator[]. While you have multiple subscripts, the cleanest way to do it is along with operator () instead of with operator[]. The reason is that

CarDealership, ABC Car Dealership needs your help to update the ordering sy...

ABC Car Dealership needs your help to update the ordering system. This car dealer is selling four types of vehicles: Sedan, Truck, SUV, and mini Van. And each type of vehicle can h

Amie, what happens when the following command is used? chmod u=rwx,go=r-x f...

what happens when the following command is used? chmod u=rwx,go=r-x foo

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd