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!news2.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx01.iad01.newshosting.com!newshosting.com!newspeer.monmouth.com!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: unsigned type Date: Mon, 29 Jun 2009 10:03:11 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <59O1m.404661$4m1.69194@bgtnsc05-news.ops.worldnet.att.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1246284192 8669 192.74.137.71 (29 Jun 2009 14:03:12 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 29 Jun 2009 14:03:12 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:GC68o4RCV7XWxDqavrVq0MfcOd0= Xref: g2news2.google.com comp.lang.ada:6717 Date: 2009-06-29T10:03:11-04:00 List-Id: Rob Solomon writes: > Now I'm trying to understand Mod types. The first thing to understand is that you should usually avoid modular types. ;-) > I tried this: > type card31 is mod 2_147_483_648; > type card32 is mod 4_294_967_296; You can also say "type T is mod 2**32;". But take care: it's easy to think "I want 32 bits, so I'll write 'mod 32'" -- and you get 5 bits. > c31 : Card31; > c32: Card32; > LI : Long_Integer; > and > > LI := Long_Integer(c32); A type conversion to modular will raise an exception if C32 is too big. To get around that problem, you should look up the 'Mod attribute. > How to I output c31 and c32? Modula-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. All scalar types have the 'Image attribute. Alternatively, you can instantiate the various generic packages in Text_IO for various scalar types. - Bob