Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!news.glorb.com!feeder.erje.net!feeder.news-service.com!94.75.214.39.MISMATCH!aioe.org!.POSTED!not-for-mail From: "Nasser M. Abbasi" Newsgroups: comp.lang.java.programmer Subject: Re: Arithmetic overflow checking Date: Fri, 08 Jul 2011 21:27:20 -0700 Organization: Aioe.org NNTP Server Lines: 24 Message-ID: References: <015aeb15-57db-48ab-9cd4-77f8448b632f@w24g2000yqw.googlegroups.com> Reply-To: nma@12000.org NNTP-Posting-Host: TUXTYYqX1yG7hs3zxUg7ng.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6007 On 7/6/2011 8:35 AM, rop rop wrote: > Hi, > > If I want to have arithmetic-overflow checking in all parts of an > application, > what is the most practical, simple, efficient way to achieve this? > Id like to clutter the code as little a possible... > Is there any way to instruct the JVM to include it? What? You mean you guys do not have this in Java?? It is a compiler option in Ada GNAT/gcc compiler: http://gcc.gnu.org/onlinedocs/gcc-4.3.5/gnat_ugn_unw/Run_002dTime-Checks.html "`-gnato' Enables overflow checking for integer operations. This causes GNAT to generate slower and larger executable programs by adding code to check for overflow (resulting in raising Constraint_Error as required by standard Ada semantics)." This is something that should be there in Java. --Nasser