You probably can't just look at the values of the endpoints. Consider

f(x) = x^2 - 3,

with A = -2 and B = 2.

Then f(A) = 1 and f(B) = 1. However, even though they have the same sign, there...