3 ms·
This is pretty much straight out of the daily wtf: http://thedailywtf.com/Articles/The-Disgruntled-Bomb.aspx http://thedailywtf.com/Articles/The-Disgruntled-Bom
by lukesandberg 15y ago
This is pretty much straight out of the daily wtf: http://thedailywtf.com/Articles/The-Disgruntled-Bomb.aspx http://thedailywtf.com/Articles/The-Disgruntled-Bomb.aspx
- raldi 15y agoWe have a winner: #define if(x) if(rand()<0.0001 && (x))
- iam 15y agoif(rand()>=0.0001 && (x)) that way it will fail extremely rarely and be even harder to detect!
- raldi 15y agoYou're right, they either need your change or a switch to ||
- reitzensteinm 15y agoDon't forget the #ifndef DEBUG around it - that would make it ten times harder to track down.
- nitrogen 15y agoC's rand() function returns an int >= 0, so rand() < 0.0001 will be true only when rand() returns zero. Assuming a pseudorandom number generator that uses all its possible values before repeating, you'll get a 0 approximately every 1 in RAND_MAX times you call rand().
- deleted 15y ago[deleted]