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=0.7 required=5.0 tests=BAYES_00,MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f127842852d2f03a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-11-27 17:40:09 PST Path: supernews.google.com!sn-xit-02!sn-xit-03!supernews.com!freenix!oleane.net!oleane!newsfeed.mathworks.com!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: Robert Dewar Newsgroups: comp.lang.ada Subject: Re: About conversions Date: Tue, 28 Nov 2000 01:33:12 GMT Organization: Deja.com - Before you buy. Message-ID: <8vv20o$nag$1@nnrp1.deja.com> References: <200011240739.IAA22865@bulgaria.otn.eurocopter.de> NNTP-Posting-Host: 205.232.38.240 X-Article-Creation-Date: Tue Nov 28 01:33:12 2000 GMT X-Http-User-Agent: Mozilla/4.61 [en] (OS/2; I) X-Http-Proxy: 1.0 x54.deja.com:80 (Squid/1.1.22) for client 205.232.38.240 X-MyDeja-Info: XMYDJUIDrobert_dewar Xref: supernews.google.com comp.lang.ada:2437 Date: 2000-11-28T01:33:12+00:00 List-Id: 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.