From: Robert Dewar <robert_dewar@my-deja.com>
Subject: Re: About conversions
Date: Tue, 28 Nov 2000 01:33:12 GMT
Date: 2000-11-28T01:33:12+00:00 [thread overview]
Message-ID: <8vv20o$nag$1@nnrp1.deja.com> (raw)
In-Reply-To: 200011240739.IAA22865@bulgaria.otn.eurocopter.de
In article <200011240739.IAA22865@bulgaria.otn.eurocopter.de>,
comp.lang.ada@ada.eu.org wrote:
> About -14 mod 5:
>
> > Sorry, but "mod x" always delivers values between 0 and x (x
excluded).
> > So the result is 1 and not -4.
>
> As always 0 - X = X = 0 + X:
>
> 0 - 14 mod 5 = -14 mod 5 = -(14 mod 5) /= (-14) mod 5 = 0 +
(-14) mod 5
>
Well you can always trust some Ada expert to get egg on their
face with this one (I certainly did the first time I saw it)
-14 mod 5 = -(14 mod 5) = -4
Yes, that's the way precedences work in Ada :-)
chuckle chuckle
Robert
P.S. I asked nearly every Ada expert this question, and all
got it wrong, except for Robert Eachus :-)
The reason that it is tricky is that it misdirects in a nasty
way. You know of course that there must be a trick, otherwise
why ask the question, but you are too clever, and think the
trick has to do with the way mod works on negative numbers :-)
Needless to say, it is terrible Ada style to depend on this
peculiar precedence rule for minus :-)
Sent via Deja.com http://www.deja.com/
Before you buy.
next prev parent reply other threads:[~2000-11-28 1:33 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-11-24 0:00 About conversions Christoph Grein
2000-11-28 1:33 ` Robert Dewar [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-11-23 6:21 Christoph Grein
2000-11-23 0:00 ` Wilhelm Spickermann
2000-11-23 0:00 ` Florian Weimer
2000-11-23 0:00 ` Wilhelm Spickermann
2000-11-28 2:20 ` Robert Dewar
2000-11-20 0:00 Sandro Binetti
2000-11-20 0:00 ` Ken Garlington
2000-11-20 0:00 ` Robert Dewar
2000-11-20 0:00 ` Stephen Leake
2000-11-21 0:00 ` Robert Dewar
2000-11-21 0:00 ` Warren W. Gay VE3WWG
2000-11-21 0:00 ` Robert Dewar
2000-11-21 0:00 ` Ted Dennison
2000-11-22 3:27 ` Warren W. Gay VE3WWG
2000-11-22 4:54 ` Robert Dewar
2000-11-22 0:00 ` Wes Groleau
2000-11-22 0:00 ` Ted Dennison
2000-11-22 0:00 ` Tristan Gingold
2000-11-24 0:00 ` Jean-Pierre Rosen
2000-11-24 0:00 ` Jean-Pierre Rosen
2000-11-21 2:57 ` DuckE
2000-11-21 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