--EXEMPLO
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;
procedure IntAttrs is
type BUG_RANGE is range -13..34;
Rat : INTEGER;
Dog : NATURAL;
Cat : POSITIVE;
Bug : BUG_RANGE;
begin
Rat := 12;
Bug := -11;
Put("The type INTEGER uses ");
Put(INTEGER'SIZE);
Put(" bits of memory,");
New_Line;
Put(" and has a range from ");
Put(INTEGER'FIRST);
Put(" to ");
Put(INTEGER'LAST);
New_Line;
Put(" Rat has a present value of ");
Put(Rat);
New_Line(2);
Put("The type BUG_RANGE uses ");
Put(INTEGER(BUG_RANGE'SIZE));
Put(" bits of memory,");
New_Line;
Put(" and has a range from ");
Put(INTEGER(BUG_RANGE'FIRST));
Put(" to ");
Put(INTEGER(BUG_RANGE'LAST));
New_Line;
Put(" Bug has a present value of ");
Put_Line(INTEGER(Bug));
New_Line(1);
end IntAttrs;
-- Resultado da execução
-- The type INTEGER uses 32 bits of memory,
-- and has a range from -2147483648 to 2147483647
-- Rat has a present value of 12
-- The type BUG_RANGE uses 7 bits of memory,
-- and has a range from -13 to 34
-- Bug has a present value of -11
Assinar:
Postar comentários (Atom)
Nenhum comentário:
Postar um comentário