Basically, I want to predict when the result of an operation between 2 int32's 
will overflow (addition, multiplication, exponentation).

Up to now, I was to doing it by catching overflow exceptions, but exceptions 
are quite expensive.

Now, I'm trying checking it like this (for addition):
    
    
    const MAX_INT = 0x7FFFFFFF
    
    if a > MAX_INT-1:
        # will overflow
    else:
        # will not overflow, proceed with the addition
    
    
    Run

I've also seen the __builtin_add_overflow commands (available for both Clang 
and GCC) and I'm wondering how I could use them.

Any recommendations?

Reply via email to