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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ddd2479bb7fae4af,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!not-for-mail From: maurizio.ferracini@gmail.com (Maurizio) Newsgroups: comp.lang.ada Subject: Bit manipulation Date: 7 Feb 2005 04:37:27 -0800 Organization: http://groups.google.com Message-ID: <211db0ae.0502070437.54add641@posting.google.com> NNTP-Posting-Host: 213.215.153.30 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1107779847 32697 127.0.0.1 (7 Feb 2005 12:37:27 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 7 Feb 2005 12:37:27 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:8178 Date: 2005-02-07T04:37:27-08:00 List-Id: hi, i need two hint: i need to acces to a 32 bit word (Interfaces.Unsigned_32). how i can do to take the three m.s.bit? (30,31,32) second, i need to send the 32 bit word over a Tcp connection to a C program, but socket work with usigned 8 bit word, so i need to split the 32 bit in 4 8bit word, and when i read from the socket take 4 8bit word and combine in a 32 word. i see that Ada.Unchecked_Conversion work (in an ada client/server test program) but is correct? --com_buffer_type is an array of 128 32bit word subtype Datas is Ada.Streams.Stream_Element_Array(1..512); --128*4 function To_Raw is new Ada.Unchecked_Conversion ( Source => Com_Buffer_Type, --Interfaces.Unsigned_32 Target => Datas); --Stream_Element is mod 2 ** Standard'Storage_Unit function From_Raw is new Ada.Unchecked_Conversion ( Source => Datas, Target => Com_Buffer_Type); ---------------------- best regards Maurizio