-- Chapter 3 - Programming Exercise 3 -- Chapter 3 - Program 5 with Text_IO; use Text_IO; procedure Ch03_3 is package Int_IO is new Text_IO.Integer_IO(INTEGER); use Int_IO; type BUG_RANGE is range -13..34; package Bug_IO is new Text_IO.Integer_IO(BUG_RANGE); use Bug_IO; Rat : INTEGER; Dog : NATURAL; Cat : POSITIVE; Bug : BUG_RANGE; begin Rat := 12; Dog := 23; Cat := 31; Bug := -11; Put("The type INTEGER uses "); Int_IO.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 NATURAL uses "); Int_IO.Put(NATURAL'SIZE); Put(" bits of memory,"); New_Line; Put(" and has a range from "); Rat := NATURAL'FIRST; Put(Rat); Put(" to "); Rat := NATURAL'LAST; Put(Rat); New_Line; Put(" Dog has a present value of "); Put(Dog); New_Line(2); Put("The type POSITIVE uses "); Int_IO.Put(POSITIVE'SIZE); Put(" bits of memory,"); New_Line; Put(" and has a range from "); Put(POSITIVE'FIRST); Put(" to "); Put(POSITIVE'LAST); New_Line; Put(" Cat has a present value of "); Put(Cat); New_Line(2); Put("The type BUG_RANGE uses "); Bug_IO.Put(BUG_RANGE'SIZE); Put(" bits of memory,"); New_Line; Put(" and has a range from "); Put(BUG_RANGE'FIRST); Put(" to "); Put(BUG_RANGE'LAST); New_Line; Put(" Bug has a present value of "); Put(Bug); New_Line(2); end Ch03_3; -- Result of execution -- The type INTEGER uses 16 bits of memory -- and has a range from -32768 to 32767 -- Rat has a present value of 12 -- The type NATURAL uses 16 bits of memory -- and has a range from 0 to 32767 -- Dog has a present value of 23 -- The type POSITIVE uses 16 bits of memory -- and has a range from 1 to 32767 -- Cat has a present value of 31 -- The type BUG_RANGE uses 16 bits of memory -- and has a range from -13 to 34 -- Bug has a present value of -11 -- Note; The qualitfier must be put in front of lines 29, 42, -- 57, and 70, because there are now two different ways to -- output a universal_integer. The system does not know -- which one to use so it forces you to make the decision. -- This will be completly clear to you later in this tutorial -- and even if it caused you a problem now, the frustration -- was probably worth the knowledge you gained.