Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: Arithmetic overflow checking Date: Fri, 08 Jul 2011 18:17:11 -0700 Organization: A noiseless patient Spider Lines: 16 Message-ID: References: <015aeb15-57db-48ab-9cd4-77f8448b632f@w24g2000yqw.googlegroups.com> <2rydnez7l-H5BYnTnZ2dnUVZ_vGdnZ2d@earthlink.com> <9LWdnZH2hdfmyYvTnZ2dnUVZ_vidnZ2d@posted.palinacquisition> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 9 Jul 2011 01:17:16 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="5HSAJfqnDjjLFxXZ6WBWEw"; logging-data="30391"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19OKxvunpkIBcUPdWh/vZFKTYER2cF64DE=" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 In-Reply-To: Cancel-Lock: sha1:+GoT148UOxrtjC5zFCk5aGil2ZI= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6004 On 7/8/2011 5:40 PM, Eric Sosman wrote: >> Not a single instruction to AddWithTrap, but a it does have a global >> state register, and a test/branch instrution, so you just pair up an ADD >> followed by a JO (Jump if Overflow) and that's it. Two easy instructions >> paired together, and it works the same for MUL and SUB too. (DIV can't >> overflow; think about it). > > I Am Curious, Ultraviolet: Even for Integer.MIN_VALUE / -1? Hmm, that was the description I read in the docs, or thought I read. I'm not really sure what the hardware will do in that case. One way to find out would be to try it. :)