Is it possible to catch overflow in long long multiply ?

Joe Buck Joe.Buck@synopsys.COM
Fri Jun 3 21:02:00 GMT 2005


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.



More information about the Gcc mailing list