Chapter 3: Comparing Floating Point Numbers
Comparing Floating-Point Numbers Floating-point numbers have only limited precision, and calculations can introduce roundoff errors. Take a look at this example: double r = Math.sqrt(2); double d = r * r – 2; if ( d == 0 ) System.out.println(” sqrt(2) squared minus 2 is 0″); else System.out.println(” sqrt(2) squared minus 2 is not 0 … Continue reading Chapter 3: Comparing Floating Point Numbers
Copy and paste this URL into your WordPress site to embed
Copy and paste this code into your site to embed