> How do you check over/underflow in C without wasting memory?
If your compiler is smart enough then for unsigned maths
r = a + b;
if (r < a)
will be optimized nicely. I've not checked if sdcc knows that and will
turn it into a carry check at least for uint8 and uint16.
For signed maths there is not nice portable approach because signed maths
overflow is undefined in C and indeed there are even processors where you
get a maths exception for your trouble.
Alan
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user