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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fe7dab2193ea2691 X-Google-Attributes: gid103376,public From: Ted Dennison Subject: Re: Byte sex Date: 1996/03/28 Message-ID: <315B642F.37CD@escmail.orl.mmc.com>#1/1 X-Deja-AN: 144761485 references: <4jeuej$mbq@twonky.btv.ibm.com> content-type: text/plain; charset=us-ascii organization: Lockheed Martin Marine Systems mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.01 (X11; I; HP-UX A.09.01 9000/750) Date: 1996-03-28T00:00:00+00:00 List-Id: Dale Pontius wrote: > > I suspect I'm going to have to handle the byte-sex issue, and > re-order the bytes as I read them in, in order to get a float > written by big-endian to look civil to a little-endian program. > In Modula-2 I would have declared a variant record, stuffing bytes > in in one order, and pulling the REAL out. The Ada equivalent of > the variant record looks 'safe', (tagged) so that I can't easily > do the same trick. Does Ada include any other facility to help > me here, or do I need to delve into 'Unchecked Conversions'? Unchecked_Conversion is the Ada-approved way of converting one type into another (eg: 64-bit IEEE float into an array of 8 unsigned bytes). Any other method is liable to rejected by the compiler outright, or to produce unstable results (excepting when one type was derived from the other, of course). Don't be afraid of Unchecked_Conversion. Unchecked_Conversion is your friend. Learn it, Live it, Love it. -- T.E.D. | Work - mailto:dennison@escmail.orl.mmc.com | | Home - mailto:dennison@iag.net | | URL - http://www.iag.net/~dennison |