with Ada.Text_IO;
use Ada.Text_IO;
procedure Fixed is
COARSE_PI : constant :=3.15;
type MY_FIXED is delta 0.1 range -40.0..120.0;
type ANGLE is delta 0.05 range -COARSE_PI..COARSE_PI;
Theta,Omega,Phi:ANGLE:=0.50;
FUNNY_VALUE:MY_FIXED;
package Int_IO is new Ada.Text_IO.Integer_IO(Integer);
use Int_IO;
package Fixed_IO is new Ada.Text_IO.Fixed_IO(MY_FIXED);
use Fixed_IO;
package Fixed2_IO is new Ada.Text_IO.Fixed_IO(ANGLE);
use Fixed2_IO;
package Flt_IO is new Ada.Text_IO.Float_IO(Float);
use Flt_IO;
begin
Put("Theta starts off with the value");
Put(Theta,5,2,0);
New_Line(2);
Theta:=Omega+Phi;
Theta:=Omega-Phi;
Theta:=5*Omega-2*Phi;
Theta:=ANGLE(3*Omega/Phi);
Theta:=abs(Omega-3*Phi);
FUNNY_VALUE:=5.1;
for Index in 1..10 loop
Put("Funny_Value is now");
Put(FUNNY_VALUE,5,1,0);
Put(FUNNY_VALUE,5,5,0);
FUNNY_VALUE:=MY_FIXED(FUNNY_VALUE*MY_FIXED(1.1));
New_Line;
end loop;
New_Line;
Put("MY_FIXED'delta=");
Put(MY_FIXED(MY_FIXED'Delta)); --
New_Line;
Put("MY_FIXED'FIRST = ");
Put(MY_FIXED'FIRST);
New_Line;
Put("MY_FIXED'LAST = ");
Put(MY_FIXED'LAST);
New_Line;
end Fixed;
026.Ada语言的定点类型
最新推荐文章于 2022-12-31 17:50:11 发布