Xref: utzoo comp.theory:372 comp.misc:8286 comp.lang.misc:4219 Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!wuarchive!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: <12120@goofy.megatest.UUCP> Date: 23 Feb 90 03:02:29 GMT References: <6197@bd.sei.cmu.edu> Organization: Megatest Corporation, San Jose, Ca Lines: 42 From article <6197@bd.sei.cmu.edu>, by firth@sei.cmu.edu (Robert Firth): > In article <12099@goofy.megatest.UUCP> djones@megatest.UUCP (Dave Jones) writes: > > [the 'contrary' view is that integer division should truncate towards zero] > >>Several others have told me that it 'depends on what you're doing', but so >>far nobody has come up with an example where the contrary view is a win. > > That surprises me, since there is a standard example. Several people posted candidates, but each was shot down in turn. > You have a > picture drawn on a Cartesian plane, symmetrical about the origin. > You need to scale this picture by some factor - for example, you > want to reduce its size by 50% linear. > > The obvious coordinate transformation is (x',y') = (x/2,y/2). If > division truncates towards zero, fine; otherwise, the scaled picture > is no longer symmetrical (and typically the viewer can perceive > the asymmetry). I presume that since we are using integer division, the image is some kind of a bitmap, right? This has the ring of truth to it, although it seems somewhat contrived. (How often do you have a *symetrical* digitized picture laying about that you want to scale by 1/2?) It has the ring of truth, because the problem with the 'contrary' view is precicely that it's graph is symetrical about the y-axix, which makes translating it sideways impossible. And here we have a picture which is symetrical about the y-axis. If there is a case where the 'contrary view' prevails, it will be something like this. But I'm still not convinced. A picture undergoing this transformatinon will be 'pinched' along both the x and y-axes, whether it is symetrical or not. This may or may not be obvious, depending on the picture. But I would think that the 'creases' down the middle would often be noticeable, and would be a direct consequence of the nastiness around zero. (It may not matter, but is this really a valid way to scale down a bitmap image? Seems bogus to me, because any two-by-two rectangle that has even one dot in it will get transformed into a dot.)