From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bffcdbd805329ff8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-31 10:37:57 PST Path: archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newshub2.rdc1.sfba.home.com!news.home.com!news1.rdc1.sfba.home.com.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: compile time Least Common Multiple, was Re: Ada and Internet stuff References: X-Newsreader: Tom's custom newsreader Message-ID: Date: Fri, 31 Aug 2001 17:37:56 GMT NNTP-Posting-Host: 24.7.82.199 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 999279476 24.7.82.199 (Fri, 31 Aug 2001 10:37:56 PDT) NNTP-Posting-Date: Fri, 31 Aug 2001 10:37:56 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:12611 Date: 2001-08-31T17:37:56+00:00 List-Id: >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; ...