Code:#include <limits.h>unsigned int a,b,c;unsigned char overflow;void mul() { unsigned long ab = (unsigned long)a * b; if (ab > UINT_MAX) { overflow = TRUE; } else { c = (unsigned int)ab; }}
#include <limits.h> uint16 a; uint16 b; uint32 a32 = a; uint32 b32 = b; uint32 result = a32 * b32; if(result > UINT_MAX) { /* a*b will give overflow */ }