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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3b7846f658978a27 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.66.74.225 with SMTP id x1mr1025295pav.45.1344781175117; Sun, 12 Aug 2012 07:19:35 -0700 (PDT) Path: p10ni42542800pbh.1!nntp.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!vg10g2000pbc.googlegroups.com!not-for-mail From: Robin Vowels Newsgroups: comp.lang.ada Subject: Re: can Ada give run-time error or warning for integer division with non-zero remainder? Date: Sun, 12 Aug 2012 07:19:34 -0700 (PDT) Organization: http://groups.google.com Message-ID: <1c0c49b1-d65a-4959-9975-b77977d00d01@vg10g2000pbc.googlegroups.com> References: NNTP-Posting-Host: 123.2.70.40 Mime-Version: 1.0 X-Trace: posting.google.com 1344781174 23376 127.0.0.1 (12 Aug 2012 14:19:34 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 12 Aug 2012 14:19:34 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: vg10g2000pbc.googlegroups.com; posting-host=123.2.70.40; posting-account=S_MdrwoAAAD7T2pxG2e393dk6y0tc0Le User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1,gzip(gfe) X-Received-Bytes: 1962 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-08-12T07:19:34-07:00 List-Id: On Aug 12, 11:14=A0am, "Nasser M. Abbasi" wrote: > In Ada when dividing 2 integers, the result is an integer > with the remainder ignored. =A0Hence 3/2 gives 1 > > ---------------------------------- > with Ada.Integer_Text_IO ; use Ada.Integer_Text_IO ; > > procedure foo4 is > =A0 =A0N : constant integer :=3D 3; > =A0 =A0M : integer; > > =A0 =A0begin > =A0 =A0 =A0M :=3D N/2; > =A0 =A0 =A0put(M); > > end foo4; > -------------------------- > > >gnatmake foo4.adb > >./foo4 > > =A0 =A0 =A0 =A0 =A0 =A01 > > Now, suppose I want to know that a division between 2 integers > has resulted in nonzero remainder that was thrown away. May be > because my algorithm is meant to work only for even values and > an odd value means there was a bug somewhere and I want to > know about it. Use MOD.