Article View: comp.theory
Article #2070Re: Modulus (Re: hashing function for strings)
From: Dave Jones
Date: Wed, 21 Feb 1990 01:45
Date: Wed, 21 Feb 1990 01:45
16 lines
1113 bytes
1113 bytes
In article <E1wt*4@cs.psu.edu> flee@shire.cs.psu.edu (Felix Lee) writes: > There are three things that most people would like: > quotient = -5 div 3 = -(5 div 3) = -1 > remainder = -5 mod 3 = (-5 + 6) mod 3 = 1 > 3*quotient + remainder = -5 > >Unfortunately, they're mutually contradictory. You must choose one of >them to violate. Someone will be unhappy with your decision. > I differ. The first of these, -5 div 3 == -1 is wrong. -5 div 3 is -2. Fix that, and everything is cool. Draw both versions of the 'div-3' graph, and you'll see why this makes sense. The -5 div 3 == -1 graph has an ughliness in it around zero that translates into an extra test in algorithms.
Technical Details
Message-ID:
<12077@goofy.megatest.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!decwrl!megatest!djonesReferences:
<2367@castle.ed.ac.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!decwrl!megatest!djones From: djones@megatest.UUCP (Dave Jones) Newsgroups: comp.theory,comp.misc,comp.lang.misc Subject: Re: Modulus (Re: hashing function for strings) Message-ID: <12077@goofy.megatest.UUCP> Date: 21 Feb 90 01:45:10 GMT References: <2367@castle.ed.ac.uk> Organization: Megatest Corporation, San Jose, Ca Lines: 16