Operators 帕斯卡**定义(指数)
我在寻找**求幂运算的扩展Pascal定义。我已经找了一段时间了,似乎找不到它Operators 帕斯卡**定义(指数),operators,pascal,exponent,Operators,Pascal,Exponent,我在寻找**求幂运算的扩展Pascal定义。我已经找了一段时间了,似乎找不到它 i.e 2**3 = 8 在FreePascal中,它在数学单元中实现: operator ** (bas,expo : float) e: float; inline; begin e:=power(bas,expo); end; operator ** (bas,expo : int64) i: int64; inline; begin i:=round(intpower(bas
i.e 2**3 = 8
在FreePascal中,它在数学单元中实现:
operator ** (bas,expo : float) e: float; inline;
begin
e:=power(bas,expo);
end;
operator ** (bas,expo : int64) i: int64; inline;
begin
i:=round(intpower(bas,expo));
end;
function power(base,exponent : float) : float;
begin
if Exponent=0.0 then
result:=1.0
else if (base=0.0) and (exponent>0.0) then
result:=0.0
else if (abs(exponent)<=maxint) and (frac(exponent)=0.0) then
result:=intpower(base,trunc(exponent))
else if base>0.0 then
result:=exp(exponent * ln (base))
else
InvalidArgument;
end;
function intpower(base : float;const exponent : Integer) : float;
var
i : longint;
begin
if (base = 0.0) and (exponent = 0) then
result:=1
else
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;
i:=i-1;
intpower:=intpower*base;
end;
if exponent<0 then
intpower:=1.0/intpower;
end;
end;
操作员**(bas,expo:float)e:float;内联;
开始
e:=电力(bas、世博会);
结束;
运营商**(bas,expo:int64)i:int64;内联;
开始
i:=圆形(国际电力公司(bas、世博会));
结束;
函数幂(基,指数:浮点):浮点;
开始
如果指数=0.0,则
结果:=1.0
否则,如果(基数=0.0)和(指数>0.0),则
结果:=0.0
如果(abs(指数)为0.0,则
结果:=exp(指数*ln(基数))
其他的
无效辩论;
结束;
函数intpower(基:浮点;常数指数:整数):浮点;
变量
i:长型;
开始
如果(基数=0.0)和(指数=0),则
结果:=1
其他的
开始
i:=abs(指数);
intpower:=1.0;
当我>0时
开始
而(i和1)=0 do
开始
i:=i shr 1;
基准:=sqr(基准);
结束;
i:=i-1;
intpower:=intpower*base;
结束;
如果指数在FreePascal中,则在数学单位中实现:
operator ** (bas,expo : float) e: float; inline;
begin
e:=power(bas,expo);
end;
operator ** (bas,expo : int64) i: int64; inline;
begin
i:=round(intpower(bas,expo));
end;
function power(base,exponent : float) : float;
begin
if Exponent=0.0 then
result:=1.0
else if (base=0.0) and (exponent>0.0) then
result:=0.0
else if (abs(exponent)<=maxint) and (frac(exponent)=0.0) then
result:=intpower(base,trunc(exponent))
else if base>0.0 then
result:=exp(exponent * ln (base))
else
InvalidArgument;
end;
function intpower(base : float;const exponent : Integer) : float;
var
i : longint;
begin
if (base = 0.0) and (exponent = 0) then
result:=1
else
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;
i:=i-1;
intpower:=intpower*base;
end;
if exponent<0 then
intpower:=1.0/intpower;
end;
end;
操作符**(bas,expo:float)e:float;内联;
开始
e:=电力(bas、世博会);
结束;
运营商**(bas,expo:int64)i:int64;内联;
开始
i:=圆形(国际电力公司(bas、世博会));
结束;
函数幂(基,指数:浮点):浮点;
开始
如果指数=0.0,则
结果:=1.0
否则,如果(基数=0.0)和(指数>0.0),则
结果:=0.0
如果(abs(指数)为0.0,则
结果:=exp(指数*ln(基数))
其他的
无效辩论;
结束;
函数intpower(基:浮点;常数指数:整数):浮点;
变量
i:长型;
开始
如果(基数=0.0)和(指数=0),则
结果:=1
其他的
开始
i:=abs(指数);
intpower:=1.0;
当我>0时
开始
而(i和1)=0 do
开始
i:=i shr 1;
基准:=sqr(基准);
结束;
i:=i-1;
intpower:=intpower*base;
结束;
如果是指数,你的定义是什么意思?它叫做指数运算,可能是用平方和乘法方法或其他方法实现的。大多数Pascal实现提供Exp、Ln和Power的标准函数。例如:我在寻找Pascal是如何实现的。免费Pascal不遵循扩展Pascal,我们只是在我们实现一个求幂运算符时借用了语法。Pascal标准afaik仍然需要付费才能获得,尽管其中的一部分已经在网络上浮动(基于公布的位或草稿?),编译器可以随意实现语言功能。“Pascal”的定义不一实现运算符。您在寻找哪个编译器的运算符定义?定义是什么意思?它称为幂运算,可能使用平方和乘法方法或其变体来实现。大多数Pascal实现为Exp、Ln和Power提供标准函数。例如:我在寻找r Pascal是如何实现的免费Pascal没有遵循扩展Pascal,我们只是借用了我们实现求幂运算符时的语法。Pascal标准afaik仍然需要付费才能获得,尽管部分标准已经在web上浮动(基于公开的位或草稿?)编译器可以随心所欲地实现语言功能。对于“Pascal”如何实现运算符,没有单一的定义。您在寻找哪种编译器的运算符定义?