[ Edit: I'm all wrong. See lastchance's explanation below. ]
By the way, the algorithm isn't very good. It could skip over the solution to an area where f(x) is positive (or negative) for all values between Xlower and Xupper. Once that happens, it will never find the solution.