go to previous page   go to home page  

Answer:

Value was 10.0 when the loop ended

value starts out at 0.0, and has 0.1 added to it until it reaches exactly 9.9. This is < limit, so (ideally) the loop would execute one more time to make value 10.0 . The loop then would exit.

But the variable actually ends up as 10.09999999999998 because of floating point inaccuracy.

Single precision floating point is really not very accurate. But even double precision floating point has errors. If you are not cautious with floats, your program may go belly up.


End of the Chapter

I hope you were not counting on more, because this is the end of the chapter. You may wish to review the following.


You have reached the end of the chapter.

go to previous page   go to home page