Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbosgd!gatech!seismo!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: net.math,net.lang.c,net.arch Subject: Re: Integer division Message-ID: <685@brl-smoke.ARPA> Date: Wed, 5-Feb-86 18:41:50 EST Article-I.D.: brl-smok.685 Posted: Wed Feb 5 18:41:50 1986 Date-Received: Sun, 9-Feb-86 04:49:38 EST References: <11603@ucbvax.BERKELEY.EDU> <4917@alice.UUCP> <367@mcgill-vision.UUCP> Reply-To: gwyn@brl.ARPA Organization: Ballistic Research Lab Lines: 22 Xref: watmath net.math:2804 net.lang.c:7793 net.arch:2478 What I would like is for the language to provide a notation for obtaining BOTH the quotient and the remainder of an integer division in a single operation. Too often I need both and have to go through extra overhead to get them (many computers compute both parts at the same time). (I would also like to get both the sine and the cosine of an angle in a single operation with reduced overhead, but that seems much less feasible.) This % vs. Mod debate is rather silly. C's % operator is NOT repeat NOT intended to be a modulo operator, although people often use it that way for positive operands. All reasonable mathematicians agree on what the definition of a mod b is for positive b and negative a. That should not be confused with what the result of a % b should be under similar circumstances. C intentionally hedges a bit on the meaning of % in such a case (which makes that a generally inadvisable situation to allow to arise in one's C code).