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,2370fc34f084c855 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-08-02 11:31:58 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: creating a 16 bit value from 2 8 bit values in Ada Date: 02 Aug 2002 14:21:06 -0400 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1028312975 2998 128.183.220.71 (2 Aug 2002 18:29:35 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 2 Aug 2002 18:29:35 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:27621 Date: 2002-08-02T18:29:35+00:00 List-Id: ma740988@pegasus.cc.ucf.edu (Mark) writes: > 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? Others have pointed out ' lo + 256 * hi'. Another choice is: type Double_Byte_Type is record Lo : Byte; Hi : Byte; end record; for Double_Byte_Type use record Lo at 0 range 0 .. 6; Hi at 0 range 7 .. 15; end record; for Double_Byte_Type'size use 16; function to_int_16 is new Ada.Unchecked_conversions (Source => Double_Byte_Type, Target => Interfaces.Unsigned_16); type Some_Type is record Hi_Lo : Double_Byte_Type; -- more stuff end record; One advantage of this version is it should take no code. One drawback is you have to get the byte-endianness right. -- -- Stephe