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,4afd08be1096008a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-11 23:45:17 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!paloalto-snf1.gtei.net!news.gtei.net!enews.sgi.com!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: converting floats, ints byte arrays References: <9ije24$9kg$1@fang.dsto.defence.gov.au> X-Newsreader: Tom's custom newsreader Message-ID: <0Ib37.176424$%i7.115281587@news1.rdc1.sfba.home.com> Date: Thu, 12 Jul 2001 06:45:16 GMT NNTP-Posting-Host: 24.7.82.199 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 994920316 24.7.82.199 (Wed, 11 Jul 2001 23:45:16 PDT) NNTP-Posting-Date: Wed, 11 Jul 2001 23:45:16 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:9853 Date: 2001-07-12T06:45:16+00:00 List-Id: >a byte array, ie: >type byte is mod 256; >type byte_array is array(integer range <>) of byte; >sampleRate : C.C_Float; >scalingFactor : C.C_Float; >What I want is an array where the first C.C_Float'size bytes is the sample >rate, This is a perfect job for Streams. It will produce an Ada.Streams.Stream_Element_Array rather than a "byte_array", but it's essentially the same thing. In some cases a size might not be the same as 'size, because the compiler can use the base_type'size. e.g. type little_integers is new integer range 0 .. 3; for little_integers'size use 2; would have a 'size of 2, but Streams would likely use Integer'size instead.