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 jplgodo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!ittatc!dcdwest!sdcsvax!sdcrdcf!oberon!smeagol!jplgodo!steve From: steve@jplgodo.UUCP (Steve Schlaifer x3171 156/224) Newsgroups: net.lang.c,net.arch Subject: Re: Integer division Message-ID: <561@jplgodo.UUCP> Date: Fri, 31-Jan-86 15:25:31 EST Article-I.D.: jplgodo.561 Posted: Fri Jan 31 15:25:31 1986 Date-Received: Sun, 2-Feb-86 05:42:24 EST References: <332@ism780c.UUCP> <11603@ucbvax.BERKELEY.EDU> <11610@ucbvax.BERKELEY.EDU> Distribution: net Organization: Jet Propulsion Labs, Pasadena, CA Lines: 55 Xref: watmath net.lang.c:7725 net.arch:2453 Summary: where does it say 0<=a%b, gsmith@brahms.BERKELEY.EDU (Gene Ward Smith) writes: > 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 > ....... > 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 If you think of % as returning the *mathematical* remainder of a/b then it should return a value >=0. On the other hand, to be consistent with this view, the quotient operator (/) will also have to be modified to preserve the formulae b=qa+r (0<=r!jplgodo!steve Advance Projects Group, Jet Propulsion Labs ....group3/ 4800 Oak Grove Drive, M/S 156/204 Pasadena, California, 91109 +1 818 354 3171