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=2.0 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,3b7846f658978a27,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.236.176.66 with SMTP id a42mr10967210yhm.22.1344998912915; Tue, 14 Aug 2012 19:48:32 -0700 (PDT) Path: c6ni115604019qas.0!nntp.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nrc-news.nrc.ca!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Nasser M. Abbasi" Newsgroups: comp.lang.ada Subject: can Ada give run-time error or warning for integer division with non-zero remainder? Date: Sat, 11 Aug 2012 20:14:42 -0500 Organization: Aioe.org NNTP Server Message-ID: Reply-To: nma@12000.org NNTP-Posting-Host: 9ii5QNw33OfeoTzEH8w9ug.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2012-08-11T20:14:42-05:00 List-Id: In Ada when dividing 2 integers, the result is an integer with the remainder ignored. Hence 3/2 gives 1 ---------------------------------- with Ada.Integer_Text_IO ; use Ada.Integer_Text_IO ; procedure foo4 is N : constant integer := 3; M : integer; begin M := N/2; put(M); end foo4; -------------------------- >gnatmake foo4.adb >./foo4 1 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. Is there any kind of run-time switch to tell it to check for this? I know I can always add logic myself to check for this in the code, using rem() for example (which might be the better solution actually) but I was just wondering if there is a run-time switch for this. thanks, -Nasser