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,442eb9212004f30 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,CP1252 Path: g2news1.google.com!postnews.google.com!s50g2000hsb.googlegroups.com!not-for-mail From: micronian2@gmail.com Newsgroups: comp.lang.ada Subject: Re: Problem using Ada.Text_IO.Modular_IO Date: Mon, 14 Jul 2008 09:34:34 -0700 (PDT) Organization: http://groups.google.com Message-ID: <85edeb59-f2aa-465d-9fac-ffd7ba839a5d@s50g2000hsb.googlegroups.com> References: <1215965011.20645.42.camel@K72> NNTP-Posting-Host: 199.46.200.231 Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1216053275 8157 127.0.0.1 (14 Jul 2008 16:34:35 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 14 Jul 2008 16:34:35 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s50g2000hsb.googlegroups.com; posting-host=199.46.200.231; posting-account=tXrPSAkAAAAFR3M1xqoK7TQdrNxOfPT0 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0,gzip(gfe),gzip(gfe) X-HTTP-Via: 1.0 webwasher (Webwasher 6.7.0.3295) Xref: g2news1.google.com comp.lang.ada:1153 Date: 2008-07-14T09:34:34-07:00 List-Id: Hi, In the context of using types such as Unsigned_N from Interfaces, what if you needed the bit shifting operations? From looking at the RM, they are only available for modular types defined in Interfaces: Ada2005 RM2.5.4(28) The same arithmetic operators are predefined for all signed integer types defined by a signed_integer_type_definition (see 4.5, =93Operators and Expression Evaluation=94). For modular types, these same operators are predefined, plus bit-wise logical operators (and, or, xor, and not). In addition, for the unsigned types declared in the language- defined package Interfaces (see B.2), functions are defined that provide bit-wise shifting and rotating. Of course, a good compiler would probably translate something like 2**X into a shift which is great. But what about Shift_Arithmetic_Right or Rotate_Left? If I had to define my own, then it probably would not be as efficient as a predefined one from Interfaces. It would have been nice if the Ada standard guaranteed such operations were available for user-defined modular types. --Micronian Coder On Jul 13, 9:03=A0am, Georg Bauhaus wrote: > On Sun, 2008-07-13 at 00:51 +0000, anon wrote: > > Plus, when a programmer defines their own type in Ada, Ada adds > > extra set of routines that are not based in hardware checks but softwar= e, > > which slows a program down. > > I'm not sure there is some real context here. =A0There is no loss > in speed and no cost in terms of additional checks for using > either Unsigned_64 or "mod 2**64". (Or "mod 2**(something smaller)".) > Below is an example to serve as one of many (really unnecessary) > proofs that there is no overhead stemming from user defined types > "mod 2**N". =A0(And no overhead stemming from user defined types > in general---they are there for a reason in this real-time > systems programming language, I should think.) > [Example code removed]