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: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Arithmetic overflow checking Date: Fri, 08 Jul 2011 20:40:06 -0400 Organization: A noiseless patient Spider Lines: 20 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 00:40:08 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="BrOwaJANne849xlH+KPYjQ"; logging-data="19471"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+1rDY+VmwGZKijCmZYEvOh" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 In-Reply-To: Cancel-Lock: sha1:UOptciFuoxVFQnOteUij9ZQZWyQ= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6002 On 7/8/2011 10:38 AM, markspace wrote: > On 7/8/2011 1:29 AM, Peter Duniho wrote: > >> AFAIK, mainstream hardware (e.g. x86-compatible) doesn't include special >> overflow-checking instructions as you're describing. I agree it's > > Er, x86 and i32/64 certainly does. I just happen to be browsing their > hardware architecture documents last weak. > > 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? -- Eric Sosman esosman@ieee-dot-org.invalid