Question

In: Computer Science

Overflow. Find out what happens when you try to add two numbers whose sum exceeds the...

  1. Overflow. Find out what happens when you try to add two numbers whose sum exceeds the maximum integer value (just over two billion, one hundred million). Test two billion plus two billion. What result did you get? Explain why overflow happens on a computer.
  2. Explain inexact results on integer division such as: 2 / 5 = 0 and 51 / 25 = 2

Solutions

Expert Solution

SOLUTION

EXPLANATION

WE GET A NEGAIVE NUMBER, BECAUSE WHEN OVERFLOW OCCURS AT 2'S COMLEMENT AND IT AGAIN STARTS FROM NEGATIVE BOUNDARY. LIKE FOR INT RANGE IS (-2147483648,2147483647). SO WHEN 2 BILLION + 2 BILLION COMES. IT WILL ADD TILL MAX VALUE THEN STARTS ROTATING i.e. ADDING IN NEGATIVE BOUNDARY.

NOW, IN 2B+2B, [2B +147483647 + 1852516353 = 2147483647 +1852516353]. NOW AFTER ADDING 1 OVERFLOW OCCURS AND IT STARTS ROTATING AND IT BECOMES [-2147483648 + 1852516352 = -294967296]

EXPLANATION

WE GET INEXACT RESULT ON INTEGER DIVISION BECAUSE. INTEGERS ARE THE NUMBERS THAT CAN BE WRITTENED WITHOUT FRACTIONAL COMPONENT. SO WHILE DIVIDING A NUMBER. IT ONLY CONSIDERS ITS NON-FRACTIONAL PART AND EXCLUDES ITS FRACTIONAL COMPONENT. FOR 2/5 ANSWER IS 0.4, BUT IT EXCLUDES .4 AND KEEPS ONLY 0 THAT IS ITS INTEGER VALUE. FOR 51/25 = 2.04, IT ONLY KEEPS INT VALUE THAT IS 2.

##### FOR ANY QUERY, KINDLY GET BACK, THANKYOU. #####


Related Solutions

Two dice are rolled. 1. Find the probability of getting two numbers whose sum is greater...
Two dice are rolled. 1. Find the probability of getting two numbers whose sum is greater than 10 2. Find the probability of getting two numbers whose sum is less than 13. 3. Find the probability of getting two numbers whose sum is less than or equal to 10.
Find three positive numbers whose sum is 400 and whose product is a maximum. show all...
Find three positive numbers whose sum is 400 and whose product is a maximum. show all steps or don't solve please
The sum of two numbers is 35 and their difference is 13. Find the numbers?
The sum  of two numbers is 35 and their difference is 13. Find the numbers?
When adding two signed binary numbers , what does it mean when unsigned overflow has occured?...
When adding two signed binary numbers , what does it mean when unsigned overflow has occured? What is the result of subtracting 1000 from 0001? What, if any, overflows would occur?
The sum of two numbers is 34. a)Find the largest possible product of these numbers.
  1-The sum of two numbers is 34.    a)Find the largest possible product of these numbers.    b)What would be the largest possible product if the sum if the two numbers were "k"? 2-Sixty meters of fencing are used to fence a rectangular garden.    a)Find the dimensions that will give that maximum area.    b)What would be the maximum area if "k" feet of fencing were used in terms of "k"? THANK YOU
a. Two dice are rolled; find the probability that the sum of the two numbers is...
a. Two dice are rolled; find the probability that the sum of the two numbers is 7. b. If one card is drawn from a standard deck, find the probability of getting a spade card or a Queen. c. A couple has 3 children, find the probability that exactly one are girls.
Consider Cardano's problem of finding two numbers whose sum is 10 and whose product is 40....
Consider Cardano's problem of finding two numbers whose sum is 10 and whose product is 40. a) Cardano knew beforehand that no such (real) numbers existed. How did he know? Can you prove it? b) Solve the system of equations x+y=10 and xy=40 to find Cardano's complex solution. c) Check that this solution does work-that is, thatb the sum of your complex numbers is 10 and that their product is 40.
Equation: f(x)=x^3-6x^2+40 Find two numbers whose product is maximum, but whose sum is 2. Repeat the...
Equation: f(x)=x^3-6x^2+40 Find two numbers whose product is maximum, but whose sum is 2. Repeat the previous problem using the product x^2 · y and the sum 2?
create two random numbers between 1 and 6. if when the sum of two numbers are...
create two random numbers between 1 and 6. if when the sum of two numbers are added togethere their sum is less than 5 or greater than 12, output to the console: "you win". if is not, output "you lose" C++
You try to find out whether a coin is fair or has two heads. The coin...
You try to find out whether a coin is fair or has two heads. The coin is tossed three times, after which you will be shown the outcome of all three coin tosses. If you decide to conclude that the coin is fair if it shows heads and tails at least once, and unfair if all three tosses are heads, what is the probability of committing a type I error and a type II error?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT