Name: OnePissedCustomer 2007-03-01 7:21 ID:Sj4eeSQv
So, the other day I was writing a loop that would index over a field backwards.
I had:
I though it would be really clever to go
Turns out that the C modulo operation, against all common logic, returns NEGATIVE values for a % b when a<0 and b>0. Just...Wow...
[INSERT PYTHON/PERL/RUBY/PHP/JAVA FANBOYISM HERE]
I had:
FRAME Frame_Tbl[MAX_FRAME]
int index = some value less than MAX_FRAME and greater than 0I though it would be really clever to go
index = (index - 1)%MAX_FRAME because I was, at that point, convinced that -1 % MAX_FRAME was equal to MAX_FRAME - 1. Ran the program. Segmentation fault. What the fuck?Turns out that the C modulo operation, against all common logic, returns NEGATIVE values for a % b when a<0 and b>0. Just...Wow...
[INSERT PYTHON/PERL/RUBY/PHP/JAVA FANBOYISM HERE]