I've been going through a java tutorial, and ran across some strangeness in this small example...
Code:
class SqrRoot {
public static void main(String args[]) {
double num,sroot,rerr,resquare;
for(num = 1.0; num < 100.0; num++) {
sroot = Math.sqrt(num);
System.out.println("Square root of " + num + " is " + sroot);
// compute rounding error
resquare = (sroot * sroot);
rerr = num - resquare;
System.out.println("Rounding error: num + " - " + resquare + " = " + rerr);
System.out.println();
}
}
}