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-16 07:15:10 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!cambridge1-snf1.gtei.net!news.gtei.net!bos-service1.ext.raytheon.com!dfw-service2.ext.raytheon.com.POSTED!not-for-mail Message-ID: <3CE3BB66.B31EB6A0@raytheon.com> From: Mark Johnson X-Mailer: Mozilla 4.76 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Signed integer to modular type conversion References: <3CE26A21.3EC6F802@raytheon.com> <5ee5b646.0205160153.75230135@posting.google.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Thu, 16 May 2002 09:00:06 -0500 NNTP-Posting-Host: 192.27.48.39 X-Complaints-To: news@ext.ray.com X-Trace: dfw-service2.ext.raytheon.com 1021557612 192.27.48.39 (Thu, 16 May 2002 09:00:12 CDT) NNTP-Posting-Date: Thu, 16 May 2002 09:00:12 CDT Organization: Raytheon Company Xref: archiver1.google.com comp.lang.ada:24199 Date: 2002-05-16T09:00:06-05:00 List-Id: Robert Dewar wrote: > > adam@irvine.com (Adam Beneschan) wrote in message news:... > > > Would you still use something like Z := X + ToModType(Y) [where > > ToModType is an instance of Unchecked_Conversion]? > > No, I would use a 64-bit type to compute. If you have a deficient > compiler that does not support 64-bit integers, then you have trouble, > but so what? You could have equally asked to deal with numbers in the > range 2**44, and then you would have needed a larger type anyway. > > These days, all compilers should support 64-bit integers. That's a little heavy if all he wants is a 32 bit value computed using modular arithmetic. I sent a separate reply showing the alternative by defining the mixed type arithmetic that should get the results he is looking for. --Mark PS: A long time ago, in the days of fixed point arithmetic, we used this kind of trick to do a lot of our calculations. (e.g., represent the angles of a circle as the range 0 .. 1-(1/2**15) which allowed natural ways to add angles yet preserve good precision)