Created
July 10, 2020 05:52
-
-
Save Noxwizard/8b1b2c51ab35ee8c8558af733b516fce to your computer and use it in GitHub Desktop.
Parentheses matter...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define VAL0 123 | |
#define VAL1 1*123 | |
#define VAL2 (1*123) | |
int main() | |
{ | |
int mod0 = 2 % VAL0; | |
printf("mod0: %d\n", mod0); | |
int mod1 = 2 % VAL1; | |
printf("mod1: %d\n", mod1); | |
int mod2 = 2 % VAL2; | |
printf("mod2: %d\n", mod2); | |
int mod3 = 2 % 123; | |
printf("mod3: %d\n", mod3); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./modtest | |
mod0: 2 | |
mod1: 0 | |
mod2: 2 | |
mod3: 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment