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,78b2880bc7e78e39 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-29 05:44:08 PST Path: supernews.google.com!sn-xit-03!supernews.com!news-out.usenetserver.com!news-out-sjo.usenetserver.com!news.tele.dk!195.224.53.60!nntp.news.xara.net!xara.net!gxn.net!server6.netnews.ja.net!server4.netnews.ja.net!server2.netnews.ja.net!newshost.central.susx.ac.uk!news.bton.ac.uk!not-for-mail From: John English Newsgroups: comp.lang.ada Subject: Re: RISC Date: Thu, 29 Mar 2001 13:42:44 +0100 Organization: University of Brighton Message-ID: <3AC32DC4.E4494034@bton.ac.uk> References: <3ab5d2a4$1@pull.gecm.com> NNTP-Posting-Host: straumli.it.bton.ac.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: saturn.bton.ac.uk 985869781 20882 193.62.183.204 (29 Mar 2001 12:43:01 GMT) X-Complaints-To: news@bton.ac.uk NNTP-Posting-Date: 29 Mar 2001 12:43:01 GMT X-Mailer: Mozilla 4.5 [en] (Win95; I) X-Accept-Language: en Xref: supernews.google.com comp.lang.ada:6204 Date: 2001-03-29T12:43:01+00:00 List-Id: "chris.danx" wrote: > I really need to know how to detect overflow for multiplication and > division. I also need a way to detect it for add and sub. Maybe Ada has an > attribute for this or something, Overflow detection is easy enough: for addition, you have an overflow iff the sign bits of the values you're adding together are the same but the sign of the result is different (e.g. for i >= 0, j >= 0, i + j < 0). Plan (b): have a handy non-modular type that you can convert your modular values to, then trap constraint errors. ----------------------------------------------------------------- John English | mailto:je@brighton.ac.uk Senior Lecturer | http://www.it.bton.ac.uk/staff/je Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS ** University of Brighton | -- see http://burks.bton.ac.uk -----------------------------------------------------------------