Hacker News new | past | comments | ask | show | jobs | submit login

I was waiting for them to say something like "then we take the random variable and multiply it by 3 to correct for this" and then explain some other, more subtle, bug. Looks like we all make stupid mistakes like this sometimes. I made a bug where I tried to get the month number for the next month, so you had to wrap at 12, but I just did "(current_month + 1) % 12" and left it at that, thinking for some reason that modulo works differently than it does in reality. Some stuff broke recently, due to that, and it was quite embarrassing.



I must be missing something. That is how modulo works. Well as long as January is month 0.


It seems that the issue is that `January === 1`; so when you get to December (i.e. `12`) it rolls over to 0 rather than remaining as 12.


You want (current_month % 12) + 1.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: