使用 Ada (GNAT):我需要确定给定值的 10 次方。最明显的方法是使用对数;但这无法编译。
with Ada.Numerics.Generic_Elementary_Functions;
procedure F(Value : in Float) is
The_Log : Integer := 0;
begin
The_Log := Integer(Log(Value, 10));
G(Value, The_Log);
end;
错误:
- utility.adb:495:26:“日志”不可见
- utility.adb:495:26:a-ngelfu.ads:24 的不可见声明,第 482 行的实例
- utility.adb:495:26:a-ngelfu.ads:23 处的不可见声明,第 482 行的实例
然后我尝试引用包,但这也失败了:
with Ada.Numerics.Generic_Elementary_Functions;
procedure F(Value : in Float) is
The_Log : Integer := 0;
package Float_Functions is new Ada.Numerics.Generic_Elementary_Functions (Float);
begin
The_Log := Integer(Float_Functions.Log(Value, 10));
G(Value, The_Log);
end;
错误:
- utility.adb:495:41:没有候选解释与实际相符:
- utility.adb:495:41:调用“Log”的参数太多
- utility.adb:495:53:预期类型“Standard.Float”
- utility.adb:495:53:在 a-ngelfu.ads:24 处对“Log”的调用中找到类型通用整数 ==>,第 482 行的实例