I don't doubt the need to check for division by zero. I've never heard of checking for division by negative one though!
if( *y == 0 )
return 0; //undefined
else
return *x / *y;
x, y
are pointers to int32_t
, I include this detail in case of relevance.
At runtime, if *x==0x80000000, *y==0xffffffff
, I get the error (in Xcode):
EXC_ARITHMETIC (code=EXC_I386_DIV, subcode=0x0)
All I can find online is suggestions that it is division by zero, but as you can see from the check above, and I can see from the debug window, that is not the case here.
What does the error mean, and how can I fix it?