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,64599bfe530783cd X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-19 10:25:29 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!amsnews01.chello.com!news-hub.cableinet.net!blueyonder!internal-news-hub.cableinet.net!news-text.cableinet.net.POSTED!53ab2750!not-for-mail User-Agent: Microsoft-Entourage/10.1.4.030702.0 Subject: Re: Any examples of Byte Ordering Functions From: "(see below)" Newsgroups: comp.lang.ada Message-ID: References: <1066243458.911546@master.nyc.kbcfp.com> Mime-version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit Date: Sun, 19 Oct 2003 17:25:28 GMT NNTP-Posting-Host: 82.41.184.118 X-Complaints-To: abuse@blueyonder.co.uk X-Trace: news-text.cableinet.net 1066584328 82.41.184.118 (Sun, 19 Oct 2003 18:25:28 BST) NNTP-Posting-Date: Sun, 19 Oct 2003 18:25:28 BST Organization: blueyonder (post doesn't reflect views of blueyonder) Xref: archiver1.google.com comp.lang.ada:1147 Date: 2003-10-19T17:25:28+00:00 List-Id: On 19/10/03 16:22, in article ZUxkb.3653$KA5.30672@newsfep4-glfd.server.ntli.net, "chris" wrote: > Trivial? :( Can you tell me how to do it pls? > > I have the following: > > type byte is mod 256; > type word is mod 2**16; > type dword is mod 2**32; > > for byte'size use 8; > for word'size use 16; > for dword'size use 32; > > > I can do stream -> word and back using multiplication/division for big > and little endian, but not dword. You can use shifts, ands (for masking) and ors (for combining) bit patterns in unsigned types as easily in Ada as in C. (gasp!) No need to rely on the compiler sussing out your arithmetic. -- Bill P.S. Actually, it's better than C! As well as logical shifts, you have circular (rotate) and arithmetic (sign-aware) shifts in Ada.