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)
Date: 29 Jun 93 03:23:24 GMT [thread overview]
Message-ID: <20556@goanna.cs.rmit.oz.au> (raw)
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.
next reply other threads:[~1993-06-29 3:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1993-06-29 3:23 cis.ohio-state.edu!math.ohio-state.edu!sdd.hp.com!network.ucsd.edu!munnar [this message]
-- strict thread matches above, loose matches on Subject: below --
1993-06-29 4:06 Precedence Rules (was Re: Software vendors not using Ada but C) Michael Feldman
1993-06-25 20:50 Michael Feldman
1993-06-25 15:09 Jonathan Schilling
1993-06-24 20:18 cis.ohio-state.edu!news.sei.cmu.edu!jbg
1993-06-24 15:22 magnesium.club.cc.cmu.edu!news.sei.cmu.edu!ae
1993-06-24 13:35 agate!howland.reston.ans.net!darwin.sura.net!haven.umd.edu!news.umbc.edu!
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox