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 07:38:11 -0700 Organization: A noiseless patient Spider Lines: 13 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: Fri, 8 Jul 2011 14:38:17 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="5HSAJfqnDjjLFxXZ6WBWEw"; logging-data="18261"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/p4VLw7sSx45Awlxqqw8y3V+k7o06LlNo=" 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:PY1qeZD4WWq2dbWJV0xvlJZVGR4= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5986 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).