Article View: comp.theory
Article #2110Re: Modulus (Re: hashing function for strings)
From: Stan Switzer
Date: Thu, 01 Mar 1990 15:44
Date: Thu, 01 Mar 1990 15:44
22 lines
1537 bytes
1537 bytes
In article <Er$cfg@cs.psu.edu> flee@shire.cs.psu.edu (Felix Lee) writes: > Dave Jones <djones@megatest.UUCP> 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
Technical Details
Message-ID:
<20457@bellcore.bellcore.com>Path:
arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!mips!apple!rutgers!bellcore!spectral!sjsReferences:
<2367@castle.ed.ac.uk> <12077@goofy.megatest.UUCP> <Er$cfg@cs.psu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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> <Er$cfg@cs.psu.edu> Sender: news@bellcore.bellcore.com Reply-To: sjs@bellcore.com (Stan Switzer) Organization: Bellcore Lines: 22