This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Is it possible to catch overflow in long long multiply ?
- From: Joe Buck <Joe dot Buck at synopsys dot COM>
- To: Bradley Lucier <lucier at math dot purdue dot edu>
- Cc: victor dot stinner at haypocalc dot com, gcc at gcc dot gnu dot org
- Date: Fri, 3 Jun 2005 14:01:56 -0700
- Subject: Re: Is it possible to catch overflow in long long multiply ?
- References: <f8b5182f6afb441264f8d54430e72c57@math.purdue.edu>
On Fri, Jun 03, 2005 at 03:26:19PM -0400, Bradley Lucier wrote:
> Assuming that overflow of signed integer arithmetic wraps (and what gcc
> flag do I have to set to assume this?) then here is the algorithm to
> multiply x and y with overflow detection.
Cast to unsigned; we are guaranteed that unsigned arithmetic wraps.