🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.theory
Article #2084

Re: Modulus (Re: hashing function for strings)

#2084
From: Karl Heuer
Date: Fri, 23 Feb 1990 21:12
23 lines
2046 bytes
In article <0:X1-+Fxds13@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes:
>I've got a secret for you. Engineers like a continuous div/rem as well. The
>folks who got it wrong were the physiscists, who never deal with integers
>nohow, and crystallography weenies, ditto.

As you may know, C allows the / % operator-pair to be implemented in either of
two$ ways: the reflection-invariant definition that rounds toward zero, or
the translation-invariant one that rounds toward negative infinity.  It seems
that there were some voices that didn't like that indeterminacy, and the
compromise position was to add the div() function whose result-pair would be
predictable.

For some reason--possibly to interface with other "broken" languages--the
X3J11 Committee chose to make div() round toward zero.  I think they should
have also provided a mathdiv() that rounds toward minus infinity; since they
didn't, I keep such a function in my own library.

Karl W. Z. Heuer (karl@ima.ima.isc.com or harvard!ima!karl), The Walking Lint
________
$ Strictly speaking, I suppose the implementation-defined rule could be
  something silly like "round toward negative infinity if the denominator is a
  power of two, else round toward zero", but since the choice must be
  documented, I doubt that any serious vendor will try that.
Technical Details
Message-ID: <16013@haddock.ima.isc.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!think!snorkelwacker!spdcc!ima!haddock!karl
References: <1990Feb15.211210.22950@max.sunysb.edu> <0ZqzBRm00WA1M0d5JZ@andrew.cmu.edu> <7416@ogicse.ogc.edu> <10940@saturn.ADS.COM> <E1wt*4@cs.psu.edu> <10946@saturn.ADS.COM> <981@m1.cs.man.ac.uk> <0:X1-+Fxds13@ficc.uu.net>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!think!snorkelwacker!spdcc!ima!haddock!karl
From: karl@haddock.ima.isc.com (Karl Heuer)
Newsgroups: comp.theory,comp.misc,comp.lang.misc
Subject: Re: Modulus (Re: hashing function for strings)
Message-ID: <16013@haddock.ima.isc.com>
Date: 23 Feb 90 21:12:08 GMT
References: <1990Feb15.211210.22950@max.sunysb.edu> <0ZqzBRm00WA1M0d5JZ@andrew.cmu.edu> <7416@ogicse.ogc.edu> <10940@saturn.ADS.COM> <E1wt*4@cs.psu.edu> <10946@saturn.ADS.COM> <981@m1.cs.man.ac.uk> <0:X1-+Fxds13@ficc.uu.net>
Reply-To: karl@haddock.ima.isc.com (Karl Heuer)
Organization: Interactive Systems, Cambridge, MA 02138-5302
Lines: 23