Let x be a variable of type double that is positive. A program contains the
boolean expression (Math.pow(x,0.5) == Math.sqrt(x)). Even though x
1/2
is
mathematically equivalent to p
x, the above expression returns the value false
in a student’s program. Which of the following is the most likely reason?
(A) Math.pow returns an int, while Math.sqrt returns a double.
(B) x was imprecisely calculated in a previous program statement.
(C) The computer stores floating-point numbers with 32-bit words.
(D) There is round-off error in calculating the pow and sqrt functions.
(E) There is overflow error in calculating the pow function.