comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: Query on portable bit extraction
Date: Sat, 27 Oct 2001 00:06:31 GMT
Date: 2001-10-27T00:06:31+00:00	[thread overview]
Message-ID: <3BD9FA80.C4B08A5E@acm.org> (raw)
In-Reply-To: 3BD99406.62B13405@Raytheon.com

I would recommend using a collection of bytes and ensuring that the same
bytes contain the same values on all platforms. Then extract the desired
parts of the desired bytes, combining them as required.

You can also, if you're sure the same bytes have the same values,
combine bytes into larger values using type conversions and shifts or
multiplications:

T1 := Shift_Left (Unsigned_16 (Byte_21), 8) or Unsigned_16 (Byte_22);
T2 := Shift_Right (T1, 6) and 2#0111_1111#; -- YYY_YYYY

Both work correctly regardless of endianness;

-- 
Jeff Carter
"I wave my private parts at your aunties."
Monty Python & the Holy Grail



  parent reply	other threads:[~2001-10-27  0:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-26 16:49 Query on portable bit extraction Mark Johnson
2001-10-26 17:08 ` Lutz Donnerhacke
2001-10-27  0:06 ` Jeffrey Carter [this message]
2001-10-27  4:23   ` Steven Deller
2001-10-27 16:31     ` Nick Roberts
2001-10-28  1:30       ` Jeffrey Carter
2001-10-28 19:07         ` Bit_Order useful [was Query on portable bit extraction] Nick Roberts
2001-10-29  1:23           ` Robert Dewar
2001-10-29  1:25       ` Query on portable bit extraction Robert Dewar
replies disabled

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