Talk:Days in Month
Jump to navigation
Jump to search
Strife, appreciate the rewriting the code, but you seem to have left out the test for months that are 31 days long. Plz fix.—The preceding unsigned comment was added on 22:42, 2 March 2009 by IntLibber Brautigan
- The current code is already doing that. It's the bit operator portial behind the return.
- (month & 1) gives 1 when it's an uneven month and 0 when it's an even month.
- (month > 7) gives 1 when it's a month after July and 0 otherwise.
- 30 is 11110 in the dual system. So what he does is, he manipulates the last bit with OR and XOR bitwise operators, depending on the month.
- 0|1=1, 0|0=0, 1|1=1, 1^0=1, 1^1=0, 0^0=0
- The code just needed a minor tweak to replace the 6 with a 7.
- This is a pretty clever solution... And it works *just tested* Lynch (talk|contribs) 23:19, 2 March 2009 (UTC)