comp.lang.ada
 help / color / mirror / Atom feed
From: Kevin Krieser <kkrieser01@hotmail.com>
To: Mark <ma740988@pegasus.cc.ucf.edu>
Subject: Re: creating a 16 bit value from 2 8 bit values in Ada
Date: Fri, 02 Aug 2002 19:52:56 -0500
Date: 2002-08-02T19:52:56-05:00	[thread overview]
Message-ID: <3D4B2968.7090108@hotmail.com> (raw)
In-Reply-To: a5ae824.0208011740.7f2df9dc@posting.google.com

Mark wrote:
> Could someone show me how to concatenate the Hi and Lo components? 
> The end result - obviously - would be a 16 bit value.  I've waded
> through my ada books here and keep coming up short?
> 
> 
> type SOME_TYPE is 
>   record 
>     Lo   : BYTE;
>     Hi   : BYTE;
>     X    : BOOLEAN;
>   -- more stuff
> end record;
> 
> for SOME_TYPE use
>  record
>   Lo at 0 range 0 .. 6;
>   Hi at 0 range 7 .. 15;
>   -- more stuff
> end record;  


Sorry to be picky, but the above wouldn't work.  Byte wouldn't fit in 7 
bits.

If you have some unsigned 16 bit type, called something like unsigned16, 
you could just do a big_val := unsigned16(hi) * 256 + unsigned16(lo);



-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



  parent reply	other threads:[~2002-08-03  0:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-02  1:40 creating a 16 bit value from 2 8 bit values in Ada Mark
2002-08-02  2:07 ` Darren New
2002-08-02  8:36   ` John McCabe
2002-08-02 18:21 ` Stephen Leake
2002-08-03 14:37   ` Robert Dewar
2002-08-03  0:52 ` Kevin Krieser [this message]
2002-08-03  1:59 ` SteveD
2002-08-03  2:02 ` creating a 16 bit value from 2 8 bit values in Ada (again) SteveD
replies disabled

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