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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,54889de51045a215 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-13 11:59:18 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!wn14feed!wn13feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi_feed4!attbi.com!sccrnsc03.POSTED!not-for-mail Message-ID: <3F8AF5DA.6090009@comcast.net> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: += in ada References: <4iOdnZ7WksmIbBeiXTWJig@gbronline.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.34.139.183 X-Complaints-To: abuse@comcast.net X-Trace: sccrnsc03 1066071557 24.34.139.183 (Mon, 13 Oct 2003 18:59:17 GMT) NNTP-Posting-Date: Mon, 13 Oct 2003 18:59:17 GMT Organization: Comcast Online Date: Mon, 13 Oct 2003 18:59:17 GMT Xref: archiver1.google.com comp.lang.ada:785 Date: 2003-10-13T18:59:17+00:00 List-Id: Wes Groleau wrote: > which agress with Robert E. -- it's > implementation dependent. > > A simple (though not 100% equivalent) > alternative is > > if Integer'Last / X <= Y > > (not 100% because if the product just equals > Integer'Last it will be rejected, but if > I used "<" integer division could let a few > overflow values squeak through. Ah, but if Integer'Last is prime, then that is not an issue. So on a 32 bit machine your code would be fine. The problem you describe can occur if Integer'Last is 2**15 - 1, 2**35 - 1, or 2**63 - 1. ;-) -- Robert I. Eachus "Quality is the Buddha. Quality is scientific reality. Quality is the goal of Art. It remains to work these concepts into a practical, down-to-earth context, and for this there is nothing more practical or down-to-earth than what I have been talking about all along...the repair of an old motorcycle." -- from Zen and the Art of Motorcycle Maintenance by Robert Pirsig