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 Path: g2news2.google.com!news1.google.com!news.glorb.com!news2.glorb.com!solaris.cc.vt.edu!news.vt.edu!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: unsigned type Date: Mon, 29 Jun 2009 11:40:26 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <59O1m.404661$4m1.69194@bgtnsc05-news.ops.worldnet.att.net> <62792744-daca-437b-bdee-4b8a21f7ce27@j32g2000yqh.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1246290026 9803 192.74.137.71 (29 Jun 2009 15:40:26 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 29 Jun 2009 15:40:26 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:MG+wt3rtXLOGFOj23ZjD27j31Vs= Xref: g2news2.google.com comp.lang.ada:6721 Date: 2009-06-29T11:40:26-04:00 List-Id: Ludovic Brenta writes: > - before you define modular types, explain to yourself why you need > the wrap-around semantics... That's good advice, but there is another reason to use modular types: you get more positive numbers. A typical Ada compiler will support "mod 2**N", but only "range 0..2**(N-1)-1" (where N is 64 on GNAT, for example). That's annoying, because you lose overflow checks. >...or the bitwise operators (modular types have > them, signed integer types don't). Right. An array of Boolean also has bitwise logical operators (but not arithmetic). So for implementing a 'set' as a bit map, you normally want a packed array of Boolean, whereas in C, you might use an unsigned type. - Bob