Hi I'm trying to create a new Float type with 6 digits precision. But it seems that I'm not able to use it. Here's the code from the package MyFloat_IO.ads
WITH Ada.Text_IO;
PACKAGE MyFloat_IO IS
TYPE MyFloat IS DIGITS 6 RANGE 0.0..Float'Last;
PACKAGE MyFloat_IO IS NEW Ada.Text_IO.Float_IO(MyFloat);
end MyFloat_IO;
and the main code:
WITH Ada.Text_IO;
WITH MyFloat_IO;
USE MyFloat_IO;
WITH Ada.Numerics;
PROCEDURE TEST2 IS
X : MyFloat := 3.5;
Y : CONSTANT := Ada.Numerics.Pi;
Z : MyFloat;
BEGIN -- main program
Z := X * Y;
MyFloat_IO.Put(Z);
Ada.Text_IO.New_Line;
END TEST2;
On compiling I get the error message:
14. BEGIN -- main program
15. Z := X * Y;
16. MyFloat_IO.Put(Z);
|
>>> "Put" not declared in "MyFloat_IO"
17. Ada.Text_IO.New_Line;
18. END TEST2;
What am I doing wrong?
Thanks a lot...
Update: new code as per the suggestions of T.E.D:
package MyFloat_I0.ads :
WITH Ada.Text_IO; PACKAGE MyFloat_I0 IS TYPE Instance IS DIGITS 6 RANGE 0.0..Float'Last; PACKAGE MyFloat IS NEW Ada.Text_IO.Float_IO(Instance); end MyFloat_I0;
and the main code :
WITH Ada.Text_IO; WITH MyFloat_I0; use MyFloat_I0; WITH Ada.Numerics; PROCEDURE TEST2 IS X : Instance := 3.5; Y : CONSTANT := Ada.Numerics.Pi; Z : Instance; BEGIN -- main program Z := X * Y; MyFloat.Instance.Put(Z); Ada.Text_IO.New_Line; END TEST2;
On compilation I get:
MyFloat.Instance.Put(Z);
|
>>> "Instance" not declared in "MyFloat"