Hi,
Is this code which checks if a and b when multiplied overflow correct?
/*begin code*/
#include <stdio.h>
#include <limits.h>
int check_overflow(unsigned long a,unsigned long b)
{
unsigned long t=ULONG_MAX/b;
unsigned long t1;
t1=ULONG_MAX-t*b;
if ( (a > t) || ((a == t) && (t1 > 0)) ) return 1;
return 0;
/* return ( (a > t) || ((a == t) && (t1 > 0)) );*/
}
/*end code*/
thanks in advance,
Arin