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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bf6949b8c20fe97,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-03-06 01:45:03 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: sphinx.moro@wanadoo.fr (SPHINX) Newsgroups: comp.lang.ada Subject: Semantic of the mod operator in Ada 83 Date: 6 Mar 2004 01:45:03 -0800 Organization: http://groups.google.com Message-ID: <464ad5ee.0403060145.6c03b8d9@posting.google.com> NNTP-Posting-Host: 193.249.253.35 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1078566303 30638 127.0.0.1 (6 Mar 2004 09:45:03 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 6 Mar 2004 09:45:03 +0000 (UTC) Xref: archiver1.google.com comp.lang.ada:6103 Date: 2004-03-06T01:45:03-08:00 List-Id: I just wander what is the semantic of What is the exact semantic of the function mod in that case? -- Compiler is gnat 3.15 -- modular types are not used, because the mode shall be Ada83 with text_io; use text_io; procedure counter is Size : constant := 32; type Counter is range 0 .. (2 ** 31) - 1; -- = 0..2147483647 for Counter'Size use Size; V1 : Counter := Counter'LAST; V2 : Counter := Counter'LAST; R : Counter := 0; Z : Counter := 0; function Add (Val1 :in Counter;Val2 :in Counter) return Counter is begin return ((Val1+Val2) mod Counter'Last); end Add; package counter_io is new integer_io(Counter);use counter_io; begin put("V1="); counter_io.put(V1);new_line; put("V2="); counter_io.put(V2);new_line; R := Add (V1, V2); put("R=");counter_io.put(R);new_line; --Result for GNAT 3.15 => R=-2 put("LAST=");put(Counter'Last);new_line; R := V1+V2; put("R=");counter_io.put(R);new_line; Z := R; put("Z=");counter_io.put(Z);new_line; end counter; And why there is no containt error on the direct additions Thanks for the help