comp.lang.ada
 help / color / mirror / Atom feed
From: seas.gwu.edu!mfeldman@uunet.uu.net  (Michael Feldman)
Subject: Re: Precedence Rules (was Re: Software vendors not using Ada but C)
Date: 25 Jun 93 20:50:22 GMT	[thread overview]
Message-ID: <1993Jun25.205022.29499@seas.gwu.edu> (raw)

In article <C96nFu.F4r@ddciiny.UUCP> jls@ddciiny.UUCP (Jonathan Schilling) writ
es:

[stuff deleted]
>
>Probably not.  But people do use mod with types that include negative
>numbers (like INTEGER), and unless the compiler is able to figure out
>that the operands have non-negative values, a fair amount of code will
>be generated for mod.  This is because the semantics for mod do not
>match the semantics of most machines' divide and remainder instructions,
>for negative numbers.
>
>Thus, it is a good habit to only use mod with non-negative subtypes,
>or to avoid mod and use rem (unless you really have negative operands
>and care about the semantics).
>
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. Sigh... Ever try to mechanically translate
some Pascal or Modula-2 code to Ada? Watch out.

Cheers -

Mike Feldman
------------------------------------------------------------------------
Michael B. Feldman -  co-chair, SIGAda Education Committee
Professor, Dept. of Electrical Engineering and Computer Science
The George Washington University -  Washington, DC 20052 USA
202-994-5253 (voice) - 202-994-5296 (fax) - mfeldman@seas.gwu.edu (Internet)
"Pork is what those other guys get from the Government."
------------------------------------------------------------------------

             reply	other threads:[~1993-06-25 20:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-06-25 20:50 Michael Feldman [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-29  3:23 cis.ohio-state.edu!math.ohio-state.edu!sdd.hp.com!network.ucsd.edu!munnar
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