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-Thread: a07f3367d7,caabf5265fad78e5 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!j32g2000yqh.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: unsigned type Date: Mon, 29 Jun 2009 07:18:09 -0700 (PDT) Organization: http://groups.google.com Message-ID: <62792744-daca-437b-bdee-4b8a21f7ce27@j32g2000yqh.googlegroups.com> References: <59O1m.404661$4m1.69194@bgtnsc05-news.ops.worldnet.att.net> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1246285089 9308 127.0.0.1 (29 Jun 2009 14:18:09 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 29 Jun 2009 14:18:09 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: j32g2000yqh.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.6) Gecko/2009012111 Red Hat/3.0.6-1.el5 Firefox/3.0.6,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:6719 Date: 2009-06-29T07:18:09-07:00 List-Id: Rob Solomon wrote on comp.lang.ada: > I was able to use the Natural and Positive. =A0 > > Now I'm trying to understand Mod types. > > I tried this: > type card31 is mod 2_147_483_648; > type card32 is mod 4_294_967_296; > c31 : Card31; > c32: Card32; > LI : Long_Integer; > and > > LI :=3D Long_Integer(c32); > > How to I output c31 and c32? =A0Modula-2 uses WriteCard or CardToString > and WriteString > > I tried using Put, but I got an error saying that correct procedure > could not be found, or something like that. > > Put(LI) works until the value of LI > 2**31, even for c32. Ada.Text_IO.Put_Line (Card31'Image (c31)); or package C31_IO is new Ada.Text_IO.Modular_Text_IO (Num =3D> Card31); begin C31_IO.Put (c31); But I have three suggestions: - rather than "type card31 is mod 2_147_483_648", write "type card31 is mod 2**31;" - do not declare machine-oriented types like card31 or card32 in the first place; instead, define application-oriented types like "Temperature" or whatever - before you define modular types, explain to yourself why you need the wrap-around semantics or the bitwise operators (modular types have them, signed integer types don't). -- Ludovic Brenta.