Hacker News new | ask | show | jobs
by hexo 2066 days ago
int main(void) { unsigned int n = 7; printf("%i", (-n % n)); return 0; }

this gives 4 :(

2 comments

Note that %i requires an int argument, not unsigned; you want %u.
If your int is 32 bits wide, 4 is exactly what it should give.