Different result integrating with integer bounds vs floating point bounds

I found an interesting bug (I think) involving the difference between using integer bounds and floating point bounds when integrating in Mathematica:

Why is it that this integral evaluates to positive pi when using integer bounds but -pi when using floating point bounds? What am I missing?

Very strange. Here is a variation:

Integrate[2 Sqrt[1 - x^2], {x, -1., 1/1000000}]
-4.712386980384691`

which is close to 3 Pi/2.

Let:

 ExactNumberQ[1]
 (*True*)

Then give exact answer (by symbol and precision) :

 Integrate[2 Sqrt[1 - x^2], {x, -1, 1}]
 (*PI*)

If:

ExactNumberQ[1.0]
(*False*)
Integrate[2 Sqrt[1 - x^2], {x, -1, 1.0}]
(*-3.14159*)

Gives no-exact solution an approximation.

 numbers = {1, 1., Pi, N[Pi, 7]};
 TableForm[
  Table[{x, ExactNumberQ[x], InexactNumberQ[x], Precision[x], 
    Head[x]}, {x, numbers}], 
  TableHeadings -> {{}, {"x", "exact", "approximate", "Precision", 
     "Head"}}]

A minus sign in a numerical calculation suggests an incorrect result.Looks like is a bug.

Regards M.I.

Try this:

Plot[Integrate[2  Sqrt[1 - x^2], {x, -1., t}], {t, -1, 1}]

The -2Pi jump discontinuity at zero looks like a branch cut, but of what function?

Hmm here is what that looks like:

I also did a few tests around the edge cases:

Interestingly, if either bound in the integral is floating point, it gives me -pi and if I use an integer lower bound and a floating point 0.99999 upper bound, I still get -pi. But, if I use floating point -0.99999 as lower bound and integer 1 upper bound, it gives me +pi. This also works if the upper bound is 1.0.

Interestingly, y with t set to 0.99999 is +pi, but my output 42 should be equivalent to that and it is -pi. Is anyone able to interpret what is going on?

There is no problem in version 12.3:

Hmm.. what is the difference between this:

and this:

It is the order of evaluation. In one example the integral is computed with a symbolic endpoint first, and then the symbol is replaced with numbers. In the other example the numeric endpoint is generated first, and then the integral is computed. It appears that different integration algorithms are called in the two situations, with different branch cuts.

As noted in the corresponding MSE post, a bug report has been filed for this.