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: Wed, 13 Jul 2011 09:45:22 -0500 Date: Wed, 13 Jul 2011 07:45:18 -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,comp.lang.c Subject: Re: Arithmetic overflow checking References: <015aeb15-57db-48ab-9cd4-77f8448b632f@w24g2000yqw.googlegroups.com> <2rydnez7l-H5BYnTnZ2dnUVZ_vGdnZ2d@earthlink.com> <9LWdnZH2hdfmyYvTnZ2dnUVZ_vidnZ2d@posted.palinacquisition> <3797038f-22d1-40b2-8c12-60db5a0976b8@t5g2000yqj.googlegroups.com> <4e1bf1bc$0$15671$4fafbaef@reader2.news.tin.it> <87k4bmc26v.fsf@once.weird.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 18 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 75.11.53.97 X-Trace: sv3-9kNTDRHI7xdRO8EXQA825Uko4BjlZqqGxTg4iH+AA++1ruS0jVbxvqO8Ja5iA3mNryqkcPPO0GBdnxL!OIGif6pHs5oZErXgcGTFDgfBkDPGRKlwUeBoO3kWgP5SK4Y7ar2OHg3o8tBOM2Tad6KfArgWEeU8!Flywm8Btobo2O0vDAOiBt6UYdr2GJbzeUUCiy6FYXTI= 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: 2593 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6162 comp.lang.c:8234 On 7/13/2011 12:52 AM, tm wrote: > On 13 Jul., 05:03, "Greg A. Woods" wrote: ... >> As I mentioned in another post just now, a decent compiler can use >> library routines for all arithmetic operations and thus allow all >> operations to be checked for overflow algorithmically. > > Yes, but this would have probable more overhead than checking > an overflow flag, not to mention hardware that can do this > without extra cost (trigger interrupt). I'm not convinced that there would be extra cost. The main performance costs on modern processors tend to be data movement, and mis-predicted conditional branches. The overflow check needs no additional data, and the associated conditional branches will be about as easy to predict as is possible. Patricia