Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site ucbvax.BERKELEY.EDU Path: utzoo!watmath!clyde!burl!ulysses!ucbvax!brahms!gsmith From: gsmith@brahms.BERKELEY.EDU (Gene Ward Smith) Newsgroups: net.lang.c,net.arch Subject: Re: Integer division Message-ID: <11610@ucbvax.BERKELEY.EDU> Date: Thu, 30-Jan-86 01:25:12 EST Article-I.D.: ucbvax.11610 Posted: Thu Jan 30 01:25:12 1986 Date-Received: Sat, 1-Feb-86 03:04:44 EST References: <332@ism780c.UUCP> <11603@ucbvax.BERKELEY.EDU> Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: gsmith@brahms.UUCP (Gene Ward Smith) Distribution: net Organization: University of California, Berkeley Lines: 36 Xref: watmath net.lang.c:7708 net.arch:2441 In article <11603@ucbvax.BERKELEY.EDU> weemba@brahms.UUCP (Matthew P. Wiener) writes: >In article <332@ism780c.UUCP> tim@ism780c.UUCP (Tim Smith) writes: >>[Which is preferred: (-a)%b == - (a%b) or (-a)%b >= 0 always?] >>Are there any good mathematical grounds for choosing one alternative over >>the other here? Note that I am not asking from a hardware point of view >>which is better. I want to know mathematically if one is better than >>the other. > >I have NEVER seen an instance where the first one is preferable. Not >only is it not preferable, it is just incorrect. Why such a routine >has been allowed to be 50% inaccurate in every existing language all >these years is beyond me. > >[Whether CS people should even be *allowed* to make such mathematical >decisions is another question. In C on UNIX, for example, one has >ucbvax!brahms!weemba Matthew P Wiener/UCB Math Dept/Berkeley CA 94720 Matthew has just about said it all, but since this has been my absolute *pet* gripe for some time now, I can't resist adding another $0.02 to the bill. When mathematicians define functions in a certain way, it is almost always for good reasons. I can think of only a few cases where doing things differently might be advisable (e.g., 1/Gammma(x) or 1/Gamma(x+1) instead of Gamma(x) never needs to worry about the poles so might be better on a computer, even though for theoretical perposes Gamma(x) is fine). Unless you really understand the situation, don't mess with the definitions of math functions and we will all be happier. Would CS people think |sin(x)| was as good as sin(x), or think that sqrt should be sqrt(|x|)? Then why mess around with quotient and remainder functions when you don't have a clue on God's green Earth what you are doing? Signed An Angry Number Theorist