From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3b4bed4f74b8ac49 X-Google-Attributes: gid103376,public From: whiting_ms@corning.com (whiting_ms@corning.com (Matt Whiting)) Subject: Re: GNAT messages and the not operator (pitfall alert!) Date: 1996/10/25 Message-ID: <1996Oct25.103321.1@corning.com>#1/1 X-Deja-AN: 192162716 references: organization: Corning, Incorporated newsgroups: comp.lang.ada nntp-posting-user: whiting_ms Date: 1996-10-25T00:00:00+00:00 List-Id: In article , dewar@merv.cs.nyu.edu (Robert Dewar) writes: > Here is another pitfall, pretty horrible if it hits, but fortunately rare. > Ask an Ada expert what is the value of > > -5 mod 3 > > Almost anyone (the better they know Ada, the more likely they are to make > this mistake) will strain to remember the table in the RM that talks about > negative mods, and, if they remember it right, come up with the answer of 1. > But Ada has VERY odd precedence rules which mean that the default > parenthesiztion of this expression is -(5 mod 3). The only person I > ever knew to get this right (and remember this is under conditions they > know they are being asked to answer a trick question) was Robert Eachus > (both Jean and Tuck got this wrong originally, and so did I :-) I'm really confused now. How does -(5 mod 3) yield 1? I thought 5 mod 3 would evaluate to 2 and then the unary minus would yield -2. Will someone provide a play-by-play evaluation sequence for this expression? Matt