Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!necntc!ames!amdcad!decwrl!alverson From: alverson@decwrl.dec.com (Robert Alverson) Newsgroups: comp.arch Subject: Re: Wirth's "challenge" Message-ID: <142@bacchus.DEC.COM> Date: Thu, 12-Nov-87 21:20:57 EST Article-I.D.: bacchus.142 Posted: Thu Nov 12 21:20:57 1987 Date-Received: Sun, 15-Nov-87 03:04:49 EST References: <1656@geac.UUCP> <863@winchester.UUCP> <197@m2.mfci.UUCP> <902@mips.UUCP> Reply-To: alverson@decwrl.UUCP (Robert Alverson) Organization: Digital Equipment Corporation Lines: 22 I found Wirth's reference to DIV and MOD extremely ironic. In his book, "Programming in Modula-2", he manages to define DIV the wrong way: `Integer division is denoted by DIV and truncates the quotient. For example 15 DIV 4 = 3 -15 DIV 4 = -3 15 DIV (-4) = -3 ... x MOD y is defined for positive x and y only.' If it wasn't for the examples, one could argue that he meant the floor function when he said truncate, but the examples are explicit. If one were to implement (-15 DIV 4) using shifts, the answer would be -4, at least using a two's complement representation. Bob