Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site alice.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!alice!td From: td@alice.UucP (Tom Duff) Newsgroups: net.math,net.lang.c,net.arch Subject: Re: Integer division Message-ID: <4917@alice.UUCP> Date: Fri, 31-Jan-86 10:43:15 EST Article-I.D.: alice.4917 Posted: Fri Jan 31 10:43:15 1986 Date-Received: Sat, 1-Feb-86 06:44:40 EST References: <11603@ucbvax.BERKELEY.EDU> Organization: Bell Labs, Murray Hill Lines: 58 Xref: watmath net.math:2764 net.lang.c:7717 net.arch:2443 Pardon my flamage, but what sort of nonsense is this: [in reference to divide instructions that give -(a/b)=(-a)/b] >I have NEVER seen an instance where the first one is preferable. Not >only is it not preferable, it is just incorrect. Wrong! That's the definition. It can't be incorrect. It might be different from what a number theorist wants, but by no stretch of the imagination can it be called incorrect. A mathematician should be able to to handle this elementary concept. >Why such a routine >has been allowed to be 50% inaccurate in every existing language all >these years is beyond me. Well, it's that way because that's the way it's defined in the ANSI Fortran standard, and Fortran is probably a Good Thing for a computer to support -- certainly more important than niggling know-nothing number-theoretic nonsense. Why does Fortran do it that way? Probably because the IBM 701 did it that way. Why did the IBM 701 do it that way? Well, at the time people thought that a divide instruction that satisfied certain identities was more important than mod function behavior. Certainly in most of the applications for which Fortran was designed (i.e. engineering numerical calculations) the behavior of the mod function is of minimal interest. In any case, why should you be worried that some operation you want to do isn't primitive. Most programming languages don't provide arithmetic on multivariate polynomials with arbitrary precision rational coefficients either (which I want more often than I want a number-theoretic mod function.) In any case, it's fairly easy to write: a=b%c if(a<0) a+=c I can't believe that you couldn't discover this code sequence yourself. (Note that it works whether the range of b%c is [0,c) or (-c,c) -- the C language definition allows either.) >[Whether CS people should even be *allowed* to make such mathematical >decisions is another question. In C on UNIX, for example, one has >log(-x) == log(x), a rather dangerous identity, not based on anything >comprehensible. Thus, the implementation of general exponentiation, >a**b = pow(a,b) = exp( b*log(a) ) will silently return the wrong value >if a is negative. (Try taking cube roots this way!)] This sort of nonsense makes me wonder whether the writer should be allowed to make *any* sort of decision at all. No plausible definition of the log function will let you use it to take cube roots of arbitrary reals in this manner. On a higher level of discourse, this writer (Matthew P Whiner) seems to think that mathematicians enjoy some sort of moral and intellectual superiority to engineers and computer scientists. Usually, this attitude is a symptom of envy, since mathematicians are so hard to employ, can't get decent salaries when they do find work, and have a much harder time raising grant money. The smart ones embrace computer science rather than denigrating it. The dull ones just say ``Computer Science? Pfui: that's not mathematics,'' thus demonstrating their lack of understanding of the nature of mathematics and of computer science. In summary: It is better to remain silent and be thought a fool than to speak up and remove all doubt.