home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog4 / smallint.ada < prev    next >
Encoding:
Text File  |  1991-07-01  |  1014 b   |  45 lines

  1.                                     -- Chapter 30 - Program 1
  2. with Text_IO;
  3. use Text_IO;
  4. procedure SmallInt is
  5.  
  6.    package Int_IO is new Text_IO.Integer_IO(INTEGER);
  7.    use Int_IO;
  8.  
  9.    BITS : constant := 1;
  10.    type SMALL_INTEGER is new INTEGER range -25..120;
  11.    for SMALL_INTEGER'SIZE use 8*BITS;
  12.    type BIG_ARRAY is array(1..1000) of SMALL_INTEGER;
  13.  
  14.    Number   : SMALL_INTEGER := 27;
  15.    Big_List : BIG_ARRAY;
  16.  
  17. begin
  18.  
  19.    Put("The type SMALL_INTEGER uses ");
  20.    Put(INTEGER(SMALL_INTEGER'SIZE));
  21.    Put(" bits of memory.");
  22.    New_Line;
  23.  
  24.    Put("The type BIG_ARRAY uses ");
  25.    Put(INTEGER(BIG_ARRAY'SIZE));
  26.    Put(" bits of memory.");
  27.    New_Line;
  28.  
  29. end SmallInt;
  30.  
  31.  
  32.  
  33.  
  34. -- Result of execution (as written)
  35.  
  36. -- The type SMALL_INTEGER uses      8 bits of memory.
  37. -- The type BIG_ARRAY uses   8000 bits of memory.
  38.  
  39.  
  40.  
  41. -- Result of execution (with line 11 commented out)
  42.  
  43. -- The type SMALL_INTEGER uses     16 bits of memory.
  44. -- The type BIG_ARRAY uses  16000 bits of memory.
  45.