- killed power from system unit

* move operator ** to math unit
This commit is contained in:
florian 2005-02-08 20:25:28 +00:00
parent 2ccc7d566c
commit f093fa9242
5 changed files with 43 additions and 98 deletions

View File

@ -1197,79 +1197,6 @@ type
end;
{$endif}
{$ifndef FPC_SYSTEM_HAS_POWER}
function intpower(base : real;const exponent: longint) : real;
var
i : longint;
begin
i:=abs(exponent);
intpower:=1.0;
while i>0 do
begin
while (i and 1)=0 do
begin
i:=i shr 1;
base:=sqr(base);
end;
dec(i);
intpower:=intpower*base;
end;
if exponent<0 then
intpower:=1.0/intpower;
end;
function power(bas,expo : real) : real;
var
sign: real;
begin
if bas=0.0 then
begin
if expo<>0.0 then
power:=0.0
else
HandleError(207);
end
else if expo=0.0 then
power:=1
else if (abs(expo)<=high(longint)) and (frac(expo)=0.0) then
power := intpower(bas,trunc(expo))
{ bas < 0 is not allowed }
else if bas<0.0 then
HandleError(207)
else
power:=exp(ln(bas)*expo);
end;
{$endif}
{$ifndef FPC_SYSTEM_HAS_POWER_INT64}
function power(bas,expo : int64) : int64;
begin
if bas=0 then
begin
if expo<>0 then
power:=0
else
HandleError(207);
end
else if expo=0 then
power:=1
else
begin
if bas<0 then
begin
if odd(expo) then
power:=-round(exp(ln(-bas)*expo))
else
power:=round(exp(ln(-bas)*expo));
end
else
power:=round(exp(ln(bas)*expo));
end;
end;
{$endif}
{$ifdef FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE}
@ -1331,7 +1258,11 @@ function fpc_int64_to_double(i : int64): double; compilerproc;
{
$Log$
Revision 1.30 2004-12-05 16:43:57 jonas
Revision 1.31 2005-02-08 20:25:28 florian
- killed power from system unit
* move operator ** to math unit
Revision 1.30 2004/12/05 16:43:57 jonas
* fixed power() in genmath.inc (code duplication from math.pp for **
support!)
* fixed power() in math.pp to give an error from 0^0

View File

@ -75,9 +75,6 @@
function trunc(d : ValReal) : int64;
{$endif internconstintf}
function power(bas,expo : ValReal) : ValReal;
function power(bas,expo : int64) : int64;
{$ifdef FPC_CURRENCY_IS_INT64}
function trunc(c : currency) : int64;
function trunc(c : comp) : int64;
@ -99,7 +96,11 @@
{
$Log$
Revision 1.20 2004-12-02 08:11:22 marco
Revision 1.21 2005-02-08 20:25:28 florian
- killed power from system unit
* move operator ** to math unit
Revision 1.20 2004/12/02 08:11:22 marco
* patch from peter.
Revision 1.19 2004/11/21 15:35:23 peter

View File

@ -245,17 +245,6 @@ end;
{$I genmath.inc}
operator ** (bas,expo : real) e: real;
begin
e:=power(bas,expo);
end;
operator ** (bas,expo : int64) i: int64;
begin
i:=power(bas,expo);
end;
{****************************************************************************
Subroutines for String handling
****************************************************************************}
@ -1062,7 +1051,11 @@ end;
{
$Log$
Revision 1.75 2005-02-06 20:35:54 florian
Revision 1.76 2005-02-08 20:25:28 florian
- killed power from system unit
* move operator ** to math unit
Revision 1.75 2005/02/06 20:35:54 florian
+ InitProc
Revision 1.74 2005/02/06 16:57:18 peter

View File

@ -474,10 +474,6 @@ Function odd(l:QWord):Boolean;{$ifdef INTERNCONSTINTF}[internconst:fpc_in_const_
{ float math routines }
{$I mathh.inc}
operator ** (bas,expo : real) e: real;
operator ** (bas,expo : int64) i: int64;
{****************************************************************************
Addr/Pointer Handling
****************************************************************************}
@ -772,7 +768,11 @@ const
{
$Log$
Revision 1.118 2005-02-06 20:37:31 florian
Revision 1.119 2005-02-08 20:25:28 florian
- killed power from system unit
* move operator ** to math unit
Revision 1.118 2005/02/06 20:37:31 florian
* InitProc gets an inital value
Revision 1.117 2005/02/06 20:35:54 florian

View File

@ -287,6 +287,9 @@ function power(base,exponent : float) : float;
{ base^exponent }
function intpower(base : float;const exponent : Integer) : float;
operator ** (bas,expo : float) e: float;
operator ** (bas,expo : int64) i: float;
{ number converting }
{ rounds x towards positive infinity }
@ -673,6 +676,19 @@ function intpower(base : float;const exponent : Integer) : float;
intpower:=1.0/intpower;
end;
operator ** (bas,expo : float) e: float;
begin
e:=power(bas,expo);
end;
operator ** (bas,expo : int64) i: float;
begin
i:=intpower(bas,expo);
end;
function ceil(x : float) : integer;
begin
@ -1358,12 +1374,12 @@ end;
{$endif}
{$ifndef ver1_0} // default params
function ifthen(val:boolean;const iftrue:integer; const iffalse:integer= 0) :integer;
function ifthen(val:boolean;const iftrue:integer; const iffalse:integer= 0) :integer;
begin
if val then result:=iftrue else result:=iffalse;
end;
function ifthen(val:boolean;const iftrue:int64 ; const iffalse:int64 = 0) :int64;
function ifthen(val:boolean;const iftrue:int64 ; const iffalse:int64 = 0) :int64;
begin
if val then result:=iftrue else result:=iffalse;
end;
@ -1377,7 +1393,11 @@ end;
end.
{
$Log$
Revision 1.29 2005-01-31 13:59:23 marco
Revision 1.30 2005-02-08 20:25:28 florian
- killed power from system unit
* move operator ** to math unit
Revision 1.29 2005/01/31 13:59:23 marco
* fixed
Revision 1.28 2005/01/12 20:17:39 florian