Main content
Course: AP??/College Computer Science Principles?>?Unit 1
Lesson 3: Limitations of storing numbersNumber limits, overflow, and roundoff
Problem
A scientist is running a program to calculate the volume of a cone:
radius ← 17.24
height ← 5.24
volume ← PI * (radius * radius) * (height / 3)
The code relies on the built-in constant
PI
. After running the code, the variable volume
stores 1630.9266447568566
.Their supervisor checks their results by running the same calculation on their own computer. Their program results in a
volume
of 1630.9266447564448
.The two values are very close, but not quite the same.
Which of these is the most likely explanation for the difference?
?
Related content