Does anyone know how to check for overflow in a c program?
like when:
How do I know if an overflow has occured?Code:result=var1+var2;
Printable View
Does anyone know how to check for overflow in a c program?
like when:
How do I know if an overflow has occured?Code:result=var1+var2;
>How do I know if an overflow has occured?
You cannot do so portably. If overflow is likely then using a larger data type would be a safe alternative. You can also test each value before the operation to determine if overflow is possible.
-Prelude