View Single Post
Newbie Member
30Apr2012,01:44  
Anindya1989's Avatar
Quote:
Originally Posted by Valiantangel View Post
Mmmmmm it could be because i am using %modulus so if that is the case, should i re-frame from using modulus for negative numbers?How about 0s? any help?
Yes its definitely because of the modulus. As it turns out C’s modulo operator behaves differently from the mathematically defined ones when we apply it for negative numbers.
The C90 standard does not define the result of modulus applied on negative numbers, so the result is compiler dependant.