我尝试过的:
function Get_T(I : in Integer)
return Float is
T:Float;
M:Float:=Float(I);
begin
T:=40.0*0.5**((60.0-M)/20.0); -- FLOAT NOT ACCEPTED IN EXPONENT
return T;
end Get_T;
我需要特殊的包裹吗?我一直在研究 Ada.Numerics.Generic_Elementary_Functions,但我不确定如何使用它。
最佳答案
您可以利用 Ada.Numerics.Elementary_Functions
包中定义的幂运算符:
With Ada.Numerics.Elementary_Functions;
function Get_T(I : in Integer) return Float is
use Ada.Numerics.Elementary_Functions;
T: Float;
M: Float := Float(I);
begin
T := 40.0 * 0.5 ** ((60.0 - M) / 20.0);
return T;
end Get_T;
关于floating-point - 阿达95 : How to use Float in Exponent?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46873186/