(cherry picked from commit f18d6f1c852579643b1d7c07d991242d3031c436)
@@ -906,22 +906,26 @@ end;
{$ifndef FPC_MATH_HAS_ARCTAN2}
function arctan2(y,x : float) : float;
begin
- if (x=0) then
+ if x=0 then
if y=0 then
- arctan2:=0.0
+ result:=0.0
else if y>0 then
- arctan2:=pi/2
- else if y<0 then
- arctan2:=-pi/2;
+ result:=pi/2
+ else
+ result:=-pi/2;
end
- else
- ArcTan2:=ArcTan(y/x);
- if x<0.0 then
- ArcTan2:=ArcTan2+pi;
- if ArcTan2>pi then
- ArcTan2:=ArcTan2-2*pi;
- end;
+ begin
+ if X > 0 then
+ result:=ArcTan(y/x)
+ if Y < 0.0 then
+ result:=ArcTan(y/x)-pi
+ result:=ArcTan(y/x)+pi;
+ end;
{$endif FPC_MATH_HAS_ARCTAN2}