mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 01:09:06 +02:00
* patch by Alexey Torgashin to resolve #40054
This commit is contained in:
parent
310db2ce92
commit
48b9751419
@ -398,8 +398,8 @@ function Power(base,exponent : float) : float;
|
|||||||
{ base^exponent }
|
{ base^exponent }
|
||||||
function IntPower(base : float;exponent : longint) : float;
|
function IntPower(base : float;exponent : longint) : float;
|
||||||
|
|
||||||
operator ** (bas,expo : float) e: float; inline;
|
operator ** (base,exponent : float) e: float; inline;
|
||||||
operator ** (bas,expo : int64) i: int64; inline;
|
operator ** (base,exponent : int64) res: int64;
|
||||||
|
|
||||||
{ number converting }
|
{ number converting }
|
||||||
|
|
||||||
@ -1088,16 +1088,33 @@ function intpower(base : float;exponent : longint) : float;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
operator ** (bas,expo : float) e: float; inline;
|
operator ** (base,exponent : float) e: float; inline;
|
||||||
begin
|
begin
|
||||||
e:=power(bas,expo);
|
e:=power(base,exponent);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
operator ** (bas,expo : int64) i: int64; inline;
|
operator ** (base,exponent : int64) res: int64;
|
||||||
begin
|
begin
|
||||||
i:=round(intpower(bas,expo));
|
if exponent<0 then
|
||||||
end;
|
begin
|
||||||
|
if base<=0 then
|
||||||
|
raise EInvalidArgument.Create('Non-positive base with negative exponent in **');
|
||||||
|
if base=1 then
|
||||||
|
res:=1
|
||||||
|
else
|
||||||
|
res:=0;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
res:=1;
|
||||||
|
while exponent<>0 do
|
||||||
|
begin
|
||||||
|
if exponent and 1<>0 then
|
||||||
|
res:=res*base;
|
||||||
|
exponent:=exponent shr 1;
|
||||||
|
base:=base*base;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function ceil(x : float) : integer;
|
function ceil(x : float) : integer;
|
||||||
|
Loading…
Reference in New Issue
Block a user