comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison <dennison@escmail.orl.mmc.com>
Subject: Re: Byte sex
Date: 1996/03/28
Date: 1996-03-28T00:00:00+00:00	[thread overview]
Message-ID: <315B642F.37CD@escmail.orl.mmc.com> (raw)
In-Reply-To: 4jeuej$mbq@twonky.btv.ibm.com

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         |




      reply	other threads:[~1996-03-28  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-03-28  0:00 Byte sex Dale Pontius
1996-03-28  0:00 ` Ted Dennison [this message]
replies disabled

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