Use 'if (c < a)' (or 'if (c < b)'). Regards, Håkon Hallingstad -----Original Message----- From: Verdi March [mailto:cincaipatron@gmx.net] Sent: 7. juni 2005 06:18 To: suse-programming-e@suse.com Subject: [suse-programming-e] Detect overflow when adding 2 unsigned int Hi, how do I detect if an overflow in the following? unsigned int a, b, c; a = 0xffffffff; b = 0xffffffff; c = a + b; I understand this can be done by declaring c long long and check if c > (1 << 32) - 1, but I just want to know if it's possible with c as an unsigned integer. Will the following work for all values of a and b? if (b != c - a) printf("Overflow\n"); Regards, Verdi -- Weitersagen: GMX DSL-Flatrates mit Tempo-Garantie! Ab 4,99 Euro/Monat: http://www.gmx.net/de/go/dsl -- To unsubscribe, email: suse-programming-e-unsubscribe@suse.com For additional commands, email: suse-programming-e-help@suse.com Archives can be found at: http://lists.suse.com/archive/suse-programming-e