为什么我会收到此错误?
“ADA.FLOAT_IO”不是预定义的库单元
我之前从未在ADA中写过任何内容,只是我不知道我在做什么。我使用GNAT编译。
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Float_IO; use Ada.Float_IO;
with Ada.Numerics.Elementary_Functions;
use Ada.Numerics.Elementary_Functions;
procedure MAIN is
A,B,C:Float;
W : Float;
Re, Im:Float;
begin
Put("Give A");Get(A);
Put("Give B");Get(B);
Put("Give C");Get(C);New_Line;
if A=0.0 then
Put_Line("It is not second degree polynomial");
else
W:=B*B - 4.0*A*C;
Re:=B/(2.0*A); Im:=Sqrt(Abs(W))/(2.0*A);
Put("dif = "); Put(W);New_Line;
if W<0.0 then
Put_Line("Complex ");
Put("x1 = ");Put(-Re);Put(" -j ");Put(Im);Put(" ");
Put("x2 = ");Put(-Re);Put(" +j ");Put(Im);New_Line;
else
Put_Line("Real");
Put("x1 = ");Put(-Re-Im);Put(" ");
Put("x2 = ");Put(-Re+Im);
end if;
end if;
end MAIN;
答案 0 :(得分:4)
IIRC Float_IO
是Text_IO
的孩子:Ada.Text_IO.Float_IO
。此外,这是一个通用的包。我想你想要Ada.Float_Text_IO
,它被定义为
package Ada.Float_Text_IO is new Ada.Text_IO.Float_IO (Float);