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 16:53:56 -0500 Date: Thu, 07 Jul 2011 14:53:50 -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> <1f9c17dltrhlmhifuigoa914477r4rg1e1@4ax.com> In-Reply-To: <1f9c17dltrhlmhifuigoa914477r4rg1e1@4ax.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 27 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 70.230.196.78 X-Trace: sv3-zGLVzdM7kyNb5HVZcMxEVOdBr5bBuleeCditPSp3PT8cK6I9ai5rjwtloRYncg9lIdEACC9uEU0odYl!7howlG/50Y9+jRp5O4JYg3ktTDykX+0LaXcPsjThnfGhcZss//leRM8sYMMOM6FWd4pbBYhaYhkG!7VHE9fljm6KhtvGMPqcRajz+5PWVJRgTvZphX9CdMLwGrA== 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: 2356 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5973 On 7/7/2011 2:34 PM, Gene Wirchenko wrote: > On Wed, 06 Jul 2011 22:41:54 -0700, Roedy Green > wrote: > >> On Wed, 6 Jul 2011 08:35:01 -0700 (PDT), rop rop >> wrote, quoted or indirectly quoted someone who said : >> >>> 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? >> >> the JVM does not detect it because most hardware does not. You pretty >> well have to use long instead of int and mask off and check overflow. > > Which hardware does not have overflow detection? > > x86 does have an overflow flag. So far, every instruction set I have studied has included overflow detection at the hardware level. I think the problem is more a matter of software knowing when overflow should and should not be treated as an error. Patricia