Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a C++ Program: Create a program that divide binary numbers using the Unsi

ID: 3902583 • Letter: C

Question

Create a C++ Program:

Create a program that divide binary numbers using the Unsigned Division algorithm, the Booth's Algorithm or the flowchart. The binary numbers must have at least 8 to 16 digits and you must show every step of the division in the output.

3:35 PM cise.ufl.edu I CLARO LTE Partial 001 101 1 100 +--Remainder The governing equation is as follows Dividend = Quotient . Divisor + Remainder. 3.3.2.1. Unsigned Division. The unsigned division algorithm that s similar to Booth's algorithm is shown in Figure 3.19a, with an example shown in Figure 3.19b The ALU schematic diagram in given in Figure 3.19c. The analysis of the algorithm and circuit is very similar to the preceding discussion of Booth's algorithm. M +-Divisor Q ? Dividend Count ? n, A +-0 START Shift left: A, Q AM Count ? Count-1 Quotient in Q Count 0 ENDRemainder in A A Q M 0011 0000 011 Initial values 0000 1110 Shift 1101 0000 1110 A-A+M 0001 1100 Shif 1110 0001 1100 A A+M 0011 1000 Shift A-A-M 2 (MMM) 1001 Q, 0001 0010 Shift 1110 0001 0010 A=A+M Divisor 4' Add 2 Subtract 32-bit ALU 4' write ( 4 write I Control 1 SLL Dividend Figure 3.19. Division of 32-bit Boolean number representations: (a) algorithm, (b) example using division of the unsigned integer 7 by the unsigned integer 3, and (c) 9 2

Explanation / Answer

Void unsigned_divide (unsigned int dividend,

unsigned int divisor,

unsigned int &quotient, unsigned int &remainder)

{

unsigned int t, num_bits;

unsigned int q,bit ,d;

int i ;

remainder =0;

quotient= 0;

if (divisor == 0)

return;

if (divisor> dividend) {

remainder = dividend;

return ;

}

if (divisor == dividend ) {

quotient =1;

return ;

}

num_bits =32;

while (remainder <divisor) {

bit = (dividend & 0×80000000>>31;

remainder = remainder <<1)| bit;

d= dividend;

dividend = dividend<<1;

num_bits--;

}

/* the loop, above, always goes one iteration too far.

To avoid inserting an "if" statement inside the loop the last iteration is simply reversed. */

dividend = d;

remainder = remainder >>1;

num_bits++;

for(i =0;i <num_bits; i ++) {

bit= (dividend &0×80000000)>>31;

remainder =( remainder<<1) | bit;

t= remainder- divisor;

q= !((t&0×80000000)>>31);

dividend = dividend <<1;

quotient = (quotient <<1) | q;

if (q) {

remainder = t;

}

}

}