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.0 required=5.0 tests=BAYES_00,FORGED_HOTMAIL_RCVD2, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,43ad9ab56ebde91c X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.191.41 with SMTP id gv9mr2851218pbc.5.1323894589079; Wed, 14 Dec 2011 12:29:49 -0800 (PST) Path: lh20ni22694pbb.0!nntp.google.com!news1.google.com!postnews.google.com!j10g2000vbe.googlegroups.com!not-for-mail From: Gautier write-only Newsgroups: comp.lang.ada Subject: Re: Does Ada support endiannes? Date: Wed, 14 Dec 2011 12:16:40 -0800 (PST) Organization: http://groups.google.com Message-ID: <6779f55b-e110-4673-b70b-cbd7c58f5d78@j10g2000vbe.googlegroups.com> References: <23835087-313f-427c-b37e-4ff1bdef9d57@r6g2000yqr.googlegroups.com> <108d5437-ae36-4e79-ad4e-aab3b903d0f4@gl2g2000vbb.googlegroups.com> <2f9744b6-4a45-4dd1-9621-c6f5d10166cb@r6g2000yqr.googlegroups.com> <0a7b55fd-1ecf-4a40-979c-12ce44071be9@p9g2000vbb.googlegroups.com> NNTP-Posting-Host: 85.1.223.74 Mime-Version: 1.0 X-Trace: posting.google.com 1323894588 18685 127.0.0.1 (14 Dec 2011 20:29:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 14 Dec 2011 20:29:48 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: j10g2000vbe.googlegroups.com; posting-host=85.1.223.74; posting-account=gRqrnQkAAAAC_02ynnhqGk1VRQlve6ZG User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HNKRUAELSC X-HTTP-UserAgent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.57 Safari/534.24,gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2011-12-14T12:16:40-08:00 List-Id: On 14 d=E9c, 17:16, Gerd wrote: > Are you sure the "/" and mod would work correct? > > Assume, that the Value 16#000000FF# shall be converted to > 16#FF000000#. > > Native : Integer :=3D 16#000000FF#; > > Remote : Integer; > > Remote :=3D 16#01000000# * ()Native mod 16#000000FF#); -- overflow! > > PS: The task is to exchange Integer Values between an Motorola 68k and > an Intel x86. Then you will use modular types, and with a definite size. Native: Unsigned_32; Remote: Unsigned_32; They never overflow. But typically (as you can see in Zip-Ada [1]) you won't presume anything about the native endianness. The "/" and "mod" (or faster: "Shift_Right" and "and") will do the job automatically for you. So your code will work on Intel, PowerPC, 68K - whatever - and communicate with a remote hardware or media with a specific endianness. [1] http://unzip-ada.sf.net/za_html/zip-headers__adb.htm#32_12 _________________________ Gautier's Ada programming http://gautiersblog.blogspot.com/search/label/Ada NB: follow the above link for a valid e-mail address