Is unary minus equivalent to binop minus?
My C compiler gave a warning when using a unary minus in the value unsigned
, so I fixed that warning by doing a subtraction from 0.
Now I'm wondering if the current code matches the original one:
uint32_t a, b; // assume b is initialized and non-zero
a = -b % b; // old code
a = (0-b) % b; // current code
My question is, for the same values, will b
both lines of code get the same result for a
?
+3
source to share