Path: utzoo!attcan!uunet!mcvax!hp4nl!orcenl!bengsig From: bengsig@orcenl.uucp (Bjorn Engsig) Newsgroups: comp.lang.c Subject: Negative integer div, Was: Something IBM did right (RT division of negatives). Summary: K&R doesn't care about negatives Message-ID: <179.nlunix6@orcenl.uucp> Date: 8 Nov 88 13:43:02 GMT References: <11529@bellcore.bellcore.com> <973@goofy.megatest.UUCP> Organization: ORACLE Europe, The Netherlands Lines: 14 The first edition of K&R (sorry I don't have the second) clearly says that "... the form of truncation is machine-dependent if either operand is negative." So: Many of us have a feeling of what i/j or i%j should be for negative i and/or j, but the compiler may do whatever is available on the machine as long as (i/j)*j + i%j == i (when b != 0). There is also no strict definition of i>>j for negative i. If i is unsigned, i>>j is a logical shift, if i is not unsingned, i>>j M A Y be arithmetic. -- Bjorn Engsig, ORACLE Europe \ / "Hofstaedter's Law: It always takes ..!uunet!mcvax!orcenl!bengsig X longer than you expect, even if you phone: +31 21 59 56 411 / \ take into account Hofstaedter's Law"