End of the Chapter

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page  

Answer:

10.0. The variable would start out at 0.0, and would have 0.1 added to it until it reached 9.9. This is less than the limit, so 0.1 would be added to make 10.0. The loop then would exit.

But the variable actually ends up as 10.09999999999998.

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