r/ProgrammerHumor • • Jul 20 '18

Every Time

Post image
52.2k Upvotes

749 comments sorted by

View all comments

Show parent comments

25

u/WiseassWolfOfYoitsu Jul 20 '18

Although it's a bit aggressive. %2 would be 50% of the time, which would be fairly easy to solve. Also just in one place. I prefer:

#define true (rand() % 10000 == 0)

15

u/slashuslashuserid Jul 20 '18

don't forget to seed that though, and also yours will be triggered 99.99% of the time, not 0.01%

 #include<stdlib.h>
 #include<time.h>
 srand((unsigned int)time(0));
 #ifdef true
     #undef true
 #endif
 #define true (rand() % 10000)

5

u/WiseassWolfOfYoitsu Jul 20 '18

and also yours will be triggered 99.99% of the time, not 0.01%

'doh :)

2

u/Allways_Wrong Jul 21 '18

You also want to only throw it late at night.