Consider the values A = 2.0 × 1030, B = -2.0 × 1030 C = 1.0. Assume, that the floating point numbers are represented with 32 bits. What are the values of X and Y, when the following sequence of operations are executed on a computer? X = A + B Y = A + C X = X + C Y = Y + B
Consider the values A = 2.0 × 1030, B = -2.0 × 1030 C = 1.0. Assume, that the floating point numbers are represented with 32 bits. What are the values of X and Y, when the following sequence of operations are executed on a computer? X = A + B Y = A + C X = X + C Y = Y + B Correct Answer X = 1.0, Y = 0.0
Concept:
Floating point have precision up to 6 places only.
Explanation:
Since A and B are floating point integers, and floating point have precision up to 6 places. Hence these floating point operations will give the following results.
X = A + B = 0.0
C = 1.0 and A has 1030 digits, C becomes negligible. As the precision is only up to 6 decimal places, it will remain A.
Y = A + C = A
X = X + C = 0.0 + 1.0 = 1.0
Y = Y + B = A + B = 0.0
মোঃ আরিফুল ইসলাম
Feb 20, 2025