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: 25 Jun 93 20:50:22 GMT From: seas.gwu.edu!mfeldman@uunet.uu.net (Michael Feldman) Subject: Re: Precedence Rules (was Re: Software vendors not using Ada but C) Message-ID: <1993Jun25.205022.29499@seas.gwu.edu> List-Id: In article 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." ------------------------------------------------------------------------