comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: compile time Least Common Multiple, was Re: Ada and Internet stuff
Date: Fri, 31 Aug 2001 17:37:56 GMT
Date: 2001-08-31T17:37:56+00:00	[thread overview]
Message-ID: <UXPj7.34989$sa.18017934@news1.rdc1.sfba.home.com> (raw)
In-Reply-To: xwMj7.487$F4.1245@www.newsranger.com

>Why are you doing that, though?  What you would generally want to figure
>out with a stream is the minimum number of stream elements that will be
>required to cover your data object's 'size.
  No, I'm not concerned here with converting from my data objects to stream
elements, but with encoding successive 24 bit chunks from a supplied
stream_element_array.  So I need an Unchecked_Conversion from a
subtype of stream_element_array of some length, to an array of 24 bit chunks,
so I need to know how many stream_element's are needed to make that
subtype an even multiple of 24 bits.

  type Twenty_Four_Bits is ...
  for Twenty_Four_Bits'size use 24;

  -- LCM is the Least Common Multiple of 24 and Stream_Element'size

  type Group_Of_Encodees is array(1 .. LCM/24) of Twenty_Four_Bits;
  pragma pack(Group_Of_Encodees);
  for Group_Of_Encodees'size use LCM;

  subtype Set_Of_Stream_Elements
  is Stream_Element_array(1 .. LCM/Stream_Element'size);
  -- assuming System.Storage_Unit = Stream_Element'size,
  -- then Set_Of_Stream_Elements'size = LCM = Group_Of_Encodees'size

  function SE_To_Groups is new Ada.Unchecked_Conversion -- LCM Bits to LCM Bits
    (Source=>Set_Of_Stream_Elements,
     Target=>Group_Of_Encodees);

  function Encode(Source : in Stream_Element_array) return String is
    The_Group : Group_Of_Encodees;
    si : Stream_Element_offset := Source'first;
  begin
    while si <= Source'last loop
      The_Group := SE_To_Groups(Source(si .. si+Group_Of_Encodees'length-1));
      for i in The_Group'range loop
        Encode_And_Emit(The_Group(i));  -- handle a set of 24 Bits
      end loop;
      ...



  reply	other threads:[~2001-08-31 17:37 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-24 19:22 Ada and Internet stuff Darren New
2001-08-24 19:39 ` Ted Dennison
2001-08-24 20:30   ` Pascal Obry
2001-08-24 22:03     ` Ehud Lamm
2001-08-26 15:52       ` David Botton
2001-08-26 20:32         ` Pascal Obry
2001-08-27  1:40           ` David Botton
2001-08-27  6:31             ` Ehud Lamm
2001-08-24 20:32 ` Pascal Obry
2001-08-24 23:36   ` Darren New
2001-08-24 20:39 ` Larry Kilgallen
2001-08-24 22:08 ` Marc A. Criley
2001-08-25  7:07   ` Pascal Obry
2001-08-27  1:49 ` tmoran
2001-08-27 11:04   ` Tarjei T. Jensen
2001-08-27 11:28     ` Ehud Lamm
2001-08-27 20:09       ` Pascal Obry
2001-08-27 23:10   ` David Botton
2001-08-29  5:52     ` tmoran
2001-08-29 16:28       ` Darren New
2001-08-29 17:12         ` David Botton
2001-08-29 17:32         ` Ted Dennison
2001-08-29 18:51         ` tmoran
2001-08-29 19:00           ` Darren New
2001-08-29 19:53             ` tmoran
2001-08-29 20:03               ` Darren New
2001-08-29 20:08           ` Ted Dennison
2001-08-30  7:08             ` tmoran
2001-08-31  2:39               ` tmoran
2001-08-31 13:34                 ` Ted Dennison
2001-08-31 13:46                   ` Marin David Condic
2001-08-31 17:37                     ` tmoran
2001-08-31 17:59                       ` Marin David Condic
2001-09-01 17:56                         ` tmoran
2001-08-31 13:34                 ` Marin David Condic
2001-08-31 17:52                   ` Ted Dennison
2001-08-31 18:09                     ` Marin David Condic
2001-08-31  2:53               ` compile time Least Common Multiple, was " tmoran
2001-08-31 13:43                 ` Ted Dennison
2001-08-31 17:37                   ` tmoran [this message]
2001-08-31 18:08                     ` Ted Dennison
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox