From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 29 Jun 93 03:23:24 GMT From: cis.ohio-state.edu!math.ohio-state.edu!sdd.hp.com!network.ucsd.edu!munnar i.oz.au!goanna!ok@ucbvax.Berkeley.EDU (Richard A. O'Keefe) Subject: Re: Precedence Rules (was Re: Software vendors not using Ada but C) Message-ID: <20556@goanna.cs.rmit.oz.au> List-Id: In article <1993Jun25.205022.29499@seas.gwu.edu>, mfeldman@seas.gwu.edu (Michae l Feldman) writes: > I agree. This has always been a tough one for me to get across to > students who are used to Pascal's MOD semantics, which of course has > the semantics of Ada's REM. The Pascal standard (IOS/EIC 7185:1990) says that (i mod j) is an error if j <= 0. That surprised me, I hadn't realised that it was defined for i < 0. It goes on to point out explicitly "Only for i >= 0 and j > 0 does the relation (i div j)*j + i mod j = i hold." _That_ stunned me. i div j and i mod j both defined for negative i, but not compatibly? Students who have been taught well about Pascal use the rule "Never use i div j or i mod j except when (i >= 0) and (j > 0)." I use the same rule in Ada. -- Richard A. O'Keefe; ok@goanna.cs.rmit.oz.au; RMIT, Melbourne, Australia.