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
Date: 1996-10-25T00:00:00+00:00 [thread overview]
Message-ID: <1996Oct25.103321.1@corning.com> (raw)
In-Reply-To: dewar.846163972@merv
In article <dewar.846163972@merv>, 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
next prev parent reply other threads:[~1996-10-25 0:00 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-10-24 0:00 GNAT messages and the not operator (pitfall alert!) Robert Dewar
1996-10-24 0:00 ` Robert Dewar
1996-10-25 0:00 ` whiting_ms@corning.com (Matt Whiting) [this message]
1996-10-26 0:00 ` David C. Hoos, Sr.
1996-10-27 0:00 ` Robert Dewar
1996-10-28 0:00 ` Matthew S. Whiting
1996-10-26 0:00 ` John Herro
1996-10-26 0:00 ` Matthew Heaney
1996-10-29 0:00 ` Robert Dewar
1996-10-26 0:00 ` Robert Dewar
1996-10-29 0:00 ` John Herro
1996-10-29 0:00 ` Robert Dewar
1996-10-30 0:00 ` Dr. Peter E. Obermayer
1996-10-30 0:00 ` John Herro
1996-10-30 0:00 ` Robert Dewar
1996-11-01 0:00 ` User Password expiration date extractor? Stein-Aksel Basma
1996-10-29 0:00 ` GNAT messages and the not operator (pitfall alert!) Norman H. Cohen
1996-10-29 0:00 ` whiting_ms@corning.com (Matt Whiting)
1996-10-30 0:00 ` Robert Dewar
1996-10-30 0:00 ` Norman H. Cohen
1996-11-06 0:00 ` Richard A. O'Keefe
1996-11-18 0:00 ` Norman H. Cohen
1996-11-18 0:00 ` Robert Dewar
1996-10-30 0:00 ` David C. Hoos, Sr.
1996-10-30 0:00 ` whiting_ms@corning.com (Matt Whiting)
1996-10-30 0:00 ` Norman H. Cohen
1996-11-05 0:00 ` Robert Dewar
1996-10-28 0:00 ` Cary Jamison
1996-10-29 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox