From: Mark Johnson <mark_h_johnson@raytheon.com>
Subject: Re: Signed integer to modular type conversion
Date: Thu, 16 May 2002 09:00:06 -0500
Date: 2002-05-16T09:00:06-05:00 [thread overview]
Message-ID: <3CE3BB66.B31EB6A0@raytheon.com> (raw)
In-Reply-To: 5ee5b646.0205160153.75230135@posting.google.com
Robert Dewar wrote:
>
> adam@irvine.com (Adam Beneschan) wrote in message news:<b4682ab7.0205151602.3c564c9e@posting.google.com>...
>
> > 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)
next prev parent reply other threads:[~2002-05-16 14:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-15 2:53 Signed integer to modular type conversion Adam Beneschan
2002-05-15 3:34 ` Jim Rogers
2002-05-15 14:01 ` Mark Johnson
2002-05-16 0:02 ` Adam Beneschan
2002-05-16 2:26 ` Steven Deller
2002-05-16 9:53 ` Robert Dewar
2002-05-16 13:46 ` Steve Doiel
2002-05-16 14:00 ` Mark Johnson [this message]
2002-05-16 15:52 ` Adam Beneschan
2002-05-17 2:26 ` Robert Dewar
2002-05-17 16:44 ` Frank J. Lhota
2002-05-16 13:55 ` Mark Johnson
2002-05-15 19:12 ` Robert Dewar
2002-05-15 20:28 ` Adam Beneschan
-- strict thread matches above, loose matches on Subject: below --
2002-05-15 5:43 Grein, Christoph
2002-05-16 4:39 Grein, Christoph
2002-05-16 14:13 ` Mark Johnson
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox