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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c7d533acec91ae16 X-Google-Attributes: gid103376,public From: Tucker Taft Subject: Re: Question for the folks who designed Ada95 Date: 1999/04/29 Message-ID: <3728D395.C078988A@averstar.com>#1/1 X-Deja-AN: 472482893 Content-Transfer-Encoding: 7bit Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.burl.averstar.com References: <7g2qu4$ca4$1@usenet.rational.com> <7g6upj$v5c$1@nnrp1.dejanews.com> <3727EC39.E460C803@rocketmail.com> <7g9r16$gll$1@nnrp1.dejanews.com> <925410775.940.21@news.remarQ.com> Content-Type: text/plain; charset=us-ascii Organization: AverStar (formerly Intermetrics) Burlington, MA USA Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-04-29T00:00:00+00:00 List-Id: Fraser Wilson wrote: > > paene lacrimavi postquam Robert Dewar scripsit: > > >Now, *without* going to the Ada RM, let's see if we can > >remember exactly what's going on with the etc here. Hands > >up those who remember how NOT works on non-binary modular > >types (hint: the above quote is wrong wrt NOT :-) > > not X = Y: X + Y = 0 ? Close. X + not(X) + 1 = 0. > Here's a question: has anyone ever used a modular type which was not > a power of 2, and lived to tell the tale? What was the context? It is convenient for hash functions where you want to use a prime number as the modulus. It works even if the multiply or add would otherwise overflow. It is also convenient for cyclic buffers, though I will admit that you end up having to put a comment on the "X := X + 1;" line to avoid confusing the reader, because most readers are not used to thinking about wrap-around arithmetic. Though, of course, this comment is appropriate for both binary as well as non-binary moduli, when wrap-around is expected (rather than being just a relatively rare "overflow" effect). > Fraser. -- -Tucker Taft stt@averstar.com http://www.averstar.com/~stt/ Technical Director, Distributed IT Solutions (www.averstar.com/tools) AverStar (formerly Intermetrics, Inc.) Burlington, MA USA