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 curve., find the c program to find area under the curvey=f(x) ...

find the c program to find area under the curvey=f(x)   #include float start_point, /* GLOBAL VARIABLES */ end_point, total_area;

Difference between mutex and binary semaphore, Semaphore is used to synchro...

Semaphore is used to synchronize processes. whereas mutex is used to give synchronization among threads running in the similar process.

Explain the class invariant, Explain the class invariant. - It's a cond...

Explain the class invariant. - It's a condition that ensures correct working of a class and defines all the valid states for an object. - When an object is created class inv

Decoding the messages, 6999066263304447777077766622337778 -----> message se...

6999066263304447777077766622337778 -----> message sent by the first smuggler. my name is robert---------> message decoded by the second smuggler. Where ‘0’ denotes the "space".

AREA UNDER CURVE, Write a program to find the area under the curve y = f(x)...

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

What is b-tree, B-tree: A B-tree is an also called balanced m-way tree. A ...

B-tree: A B-tree is an also called balanced m-way tree. A node of the tree may have many records or key and pointers to children. It is also called as the balanced sort tree. It s

Need squid web proxy with ffmpeg to convert flv to h.264, Need Squid Web Pr...

Need Squid Web Proxy with ffmpeg to convert flv to h.264 Project Description: We need a squid proxy setup with the modification that will transcode FLV to h.264 in real-time,

201 it, overloadstream insertion opertator to display the data of object on...

overloadstream insertion opertator to display the data of object on the console

Define the bitwise operators in c language, Define the Bitwise Operators in...

Define the Bitwise Operators in c language? C has distinction of supporting special operators that known as bit wise operators for manipulation of data at bit level. These oper

Luminous jewels, Problem : Luminous Jewels - Polishing Necklace Byteland c...

Problem : Luminous Jewels - Polishing Necklace Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of v

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