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 X-Google-Thread: 103376,f584bf624aabe591 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-14 20:34:16 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!feed2.news.rcn.net!rcn!wn4feed!worldnet.att.net!bgtnsc04-news.ops.worldnet.att.net.POSTED!not-for-mail Message-ID: <3CE1D73A.8010401@worldnet.att.net> From: Jim Rogers User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1 X-Accept-Language: en-us MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Signed integer to modular type conversion References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 15 May 2002 03:34:15 GMT NNTP-Posting-Host: 12.75.144.74 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1021433655 12.75.144.74 (Wed, 15 May 2002 03:34:15 GMT) NNTP-Posting-Date: Wed, 15 May 2002 03:34:15 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:24067 Date: 2002-05-15T03:34:15+00:00 List-Id: Adam Beneschan wrote: > Supposing Standard.Integer is a 32-bit signed integer type. I have a > modular type > > type ModType is mod 2**32; > > X : Integer; > Y : ModType; > > I'd like to set Y := X mod 2**32 (which should essentially just treat > X as an unsigned integer without changing the data). However, I can't > figure out a good way to do this in Ada. Try the following example. with Ada.Text_Io; procedure Convert is type ModType is mod 2**32; X: Integer; Y: ModType := ModType'First; begin loop X := Integer(Y); Ada.Text_IO.Put_Line("Value:" & Integer'Image(X)); exit when Y = ModType'Last; Y := Y + 1; end loop; end Convert; You can see that the only real issue is converting the modular type to an Integer, which is done with simple type coercion. Jim Rogers