Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 07 Jul 2011 12:02:44 -0500 Date: Thu, 07 Jul 2011 10:02:38 -0700 From: Patricia Shanahan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Arithmetic overflow checking References: <015aeb15-57db-48ab-9cd4-77f8448b632f@w24g2000yqw.googlegroups.com> <2rydnez7l-H5BYnTnZ2dnUVZ_vGdnZ2d@earthlink.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 32 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 70.230.196.78 X-Trace: sv3-WQEKP51rcpBwL3G9r3Dt1sH1WH0x8VBp0cOG+IeOHrRbP5T53J6h8Rka2FNCx946q4h1iz5CzfSchnU!R2cQUFMgy3w4elqB/m5/kfK0Q1iMn1pNy8I0fxXmwq6kFhp0xqntfst8LpKo1U30/7KCFSwhQS0C!/ukksE1zKeRpz5780s4uuvRBARPz3dYwXDQE8HdphG6q6Q== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2622 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5967 On 7/7/2011 7:11 AM, Peter Duniho wrote: > On 7/6/11 10:16 AM, Patricia Shanahan wrote: >> 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? >> >> Write the application in Ada. > > Or use C#, which has the same feature, but is a lot more like Java > otherwise. > > That said, I suspect Tom's guess is correct and a language-change just > to achieve this goal isn't going to be the practical choice. Like most design decisions, it is a trade-off. If Tom *needs* overflow checking, the most practical, simple, efficient way to achieve it is to use a language that is designed to support overflow checking. If he merely *wants* overflow checking, the best choice may be to stick to Java and drop general overflow checking. That does not prevent having e.g. a BigInteger subclass that takes a range as a constructor parameter and does overflow checking against that range. I have not yet seen an option for getting general overflow checking in Java, without getting false hits on code that depends on the JLS specified arithmetic behavior, that is at all practical, simple, or efficient. Patricia