Question

In: Computer Science

Problem: Perform following operations in binary using 8-bit addition/subtraction/multiplication. 1. −80 + 42 2. −99 −...

Problem: Perform following operations in binary using 8-bit addition/subtraction/multiplication.
1. −80 + 42
2. −99 − 20
3. 60 − 70
4. −59 × 3
5. 52×−1

Solutions

Expert Solution

I am providing Solution using 2's complement.

2's Complement of a binary number is " Adding 1 to 1's compliment of that number" and, 1's complement of a binary no. obtained by converting digits 0 to 1 and 1 to 0.

ADDITION / SUBTRACTION

1.)

80 in binary is = 01010000 and 42 is = 00101010

-80 = (1's compliment of 80 )+ 1

So, -80= (10101111) +1 = 10110000

now, -80 + 42 = (10110000) + (00101010) = 11011010

Here 8th bit of Sum is 1 so, number is negative.

So, to find the magnitude of no, we have to find its 2’s complement.

So, 2’s complement of 11011010= 00100101 +1 = 00100110 = 38

and though, number is negative, hence, answer is -38

2.)

99= 01100011

-99= 10011100 + 1= 10011101

20= 00010100

-20= 11101011 + 1= 11101100

So, -99 + -20 = (10011101) + (11101100) = 10001001

Here 8th bit of Sum is 1 so, number is negative.

So, to find the magnitude of no, we have to find its 2’s complement.

So, 2’s complement of 10001001= 01110110 +1 = 01110111= 119

and though, number is negative, hence, answer is -119

3.)

60= 00111100

70= 01000110

-70= 10111001+ 1= 10111010

So, 60+ (-70) = (00111100) + (10111010) = 11110110

Here 8th bit of Sum is 1 so, number is negative.

So, to find the magnitude of no, we have to find its 2’s complement.

So, 2’s complement of 11110110= 00001001 +1 = 00001010= 10

and though, number is negative, hence, answer is -10

MULTIPLICATION

5.)

52= 00110100

1= 00000001

-1= 11111110+ 1=11111111

doing normal binary multiplication of (00110100) and (11111111)


So, Output is 11001100

Here 8th bit of Sum is 1 so, number is negative.

So, to find the magnitude of no, we have to find its 2’s complement.

So, 2’s complement of 11001100= 00110011 +1 = 00110100= 52

and though, numberis negative, hence, answer is -52

I hope, this solution will help you. If You still have doubt about 2's compliment or addition/subtraction/multiplication, you can put your doubts in comment section. I would like to sort them out. THANK YOU!


Related Solutions

Write a C++ program to perform two-4 bit binary number operations including addition and subtraction. The...
Write a C++ program to perform two-4 bit binary number operations including addition and subtraction. The user will type in two-4 bit binary numbers with the selection of one of the operations. Then, the program will calculate the result of the calculation. Display two-4 bit binary numbers and the result from the calculation.
1) Perform the following addition and subtraction operations. For subtraction, negate the subtrahend (the second value)...
1) Perform the following addition and subtraction operations. For subtraction, negate the subtrahend (the second value) and add. For each operation, show the interpretation as both unsigned and signed operations. Indicate whether an unsigned or signed overflow has occurred that invalidates the result under that interpretation. Use an eight bit byte for all operations and for the signed interpretation, use two’s complement representation. Spaces are used in the binary values only for readability a. 1001 1111 + 0111 1000 b....
Write a Python program that will perform various calculations (addition, subtraction, multiplication, division, and average). The...
Write a Python program that will perform various calculations (addition, subtraction, multiplication, division, and average). The program will add, subtract, multiply, or divide 2 numbers and provide the average of multiple numbers inputted from the user. You need to define a function named performCalculation which takes 1 parameter. The parameter will be the operation being performed (+,-,*,/). This function will perform the given prompt from the user for 2 numbers then perform the expected operation depending on the parameter that’s...
Write a Behavioral model VHDL code that implements an ALU that can perform addition, subtraction, multiplication,...
Write a Behavioral model VHDL code that implements an ALU that can perform addition, subtraction, multiplication, shift right, shift left, logical NAND, and logical NOR. Write a VHDL test bench to test the ALU with at least one test vector per operation.
You are supposed to build a custom ALU that can perform the following operations: Multiplication Addition...
You are supposed to build a custom ALU that can perform the following operations: Multiplication Addition Division Logical OR Select all necessary components below, to create this ALU. Multiplexer Demultiplexer OR gate AND gate NOT gate Encoder Priority Encoder Decoder Adder Subtractor Multiplier Divider Shifter Register Register File
Problem 5: Perform the subtraction on the following pairs of signed numbers using the 2’s complement...
Problem 5: Perform the subtraction on the following pairs of signed numbers using the 2’s complement system. Express the results as signed binary numbers and as decimal values. Please show all work to fully understand. A. 01001 - 11010 B. 10010 - 10011
Represent -60 in binary using 8-bit signed magnitude. Add the following unsigned 8 bit binary numbers...
Represent -60 in binary using 8-bit signed magnitude. Add the following unsigned 8 bit binary numbers as shown. 01110101 + 00111011 Add the following unsigned 8 bit binary numbers as shown. 01000100 + 10111011
Q6. Perform the following operations using bit masking. (a) Set the bit 3 of a byte...
Q6. Perform the following operations using bit masking. (a) Set the bit 3 of a byte data (b) Clear the bit 5 of a byte data (c) Toggle the bit 7 of a byte data (d) Check the bit 0 of a byte data
1-How is -89 represented using 8-bit two's compliment? (The answer should be 8 binary digits). 2-What...
1-How is -89 represented using 8-bit two's compliment? (The answer should be 8 binary digits). 2-What is 10101100 - 00100100 using 2's compliment arithmetic? (The answer should be 8 binary digits) 3-Assume we are using the simple model for floating-point representation as given in the text (the representation uses a 14-bit format, 5 bits for the exponent with a bias of 15, a normalized mantissa of 8 bits, and a single sign bit for the number):Show how the computer would...
Problem 1. Suppose that R is a commutative ring with addition “+” and multiplication “·”, and...
Problem 1. Suppose that R is a commutative ring with addition “+” and multiplication “·”, and that I a subset of R is an ideal in R. In other words, suppose that I is a subring of R such that (x is in I and y is in R) implies x · y is in I. Define the relation “~” on R by y ~ x if and only if y − x is in I, and assume for the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT