• Create Account

### #Actuallightxbulb

Posted 30 April 2013 - 01:35 AM

Careful now...

    if(input>6) //this condition is (usually) not an effective optimization and is mathematically irrelevant
input = input % 7;
if(input<0)
input = (input % 7) + 7; //this is incorrect in cases where input == n * -7

Try:

    input %= 7;
if(input<0)
input +=  7;

(In fact I think I did predict it but messed up my conditionals...  gotta be careful when coding)

### #1lightxbulb

Posted 30 April 2013 - 01:00 AM

Careful now...

    if(input>6) //this condition is (usually) not an effective optimization and is mathematically irrelevant
input = input % 7;
if(input<0)
input = (input % 7) + 7; //this is incorrect in cases where input == n * -7

Try:

    input %= 7;
if(input<0)
input +=  7;