Xref: utzoo comp.theory:402 comp.misc:8369 comp.lang.misc:4298 Path: utzoo!censor!geac!torsqnt!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!mips!apple!rutgers!bellcore!spectral!sjs From: sjs@spectral.ctt.bellcore.com (Stan Switzer) Newsgroups: comp.theory,comp.misc,comp.lang.misc Subject: Re: Modulus (Re: hashing function for strings) Message-ID: <20457@bellcore.bellcore.com> Date: 1 Mar 90 15:44:01 GMT References: <2367@castle.ed.ac.uk> <12077@goofy.megatest.UUCP> Sender: news@bellcore.bellcore.com Reply-To: sjs@bellcore.com (Stan Switzer) Organization: Bellcore Lines: 22 In article flee@shire.cs.psu.edu (Felix Lee) writes: > Dave Jones wrote: > >I differ. The first of these, -5 div 3 == -1 is wrong. > > The contrary view is that abs(a/b) != abs(-a/b) is strange. It > depends on what you're doing. I have no problems with either stance. Put up or shut up. I have often found that the anomalous behavior of "modulus" at zero has caused me extra work to make it do the "right" thing: -5 div 3 == -2 -5 mod 3 == 1 This has occurred in graphics applications, in communications handlers (computing sliding windows using a wrap-around counter), and others. Please, somebody, show me a single example where the other behavior is actually USEFUL! We are not concerned with whether your grade-school education [ -a/b == -(a/b) ] applies to computers, but with what actually is useful in integer computation in actual algorithms. Stan Switzer sjs@bellcore.com