Difference between revisions of "Talk:Days in Month"

From Second Life Wiki
Jump to navigation Jump to search
(New page: Strife, appreciate the rewriting the code, but you seem to have left out the test for months that are 31 days long. Plz fix.)
 
m
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
Strife, appreciate the rewriting the code, but you seem to have left out the test for months that are 31 days long. Plz fix.
Strife, appreciate the rewriting the code, but you seem to have left out the test for months that are 31 days long. Plz fix.{{unsigned|IntLibber Brautigan|22:42, 2 March 2009}}
 
: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 [[LSL_Operators|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* [[Image:Zai_signature.png|45px]] '''[[User:Zai Lynch|Lynch]]''' <sup><small>([[User talk:Zai Lynch|talk]]|[[Special:Contributions/Zai Lynch|contribs]])</small></sup> 23:19, 2 March 2009 (UTC)

Latest revision as of 15:36, 2 March 2009

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* Zai signature.png Lynch (talk|contribs) 23:19, 2 March 2009 (UTC)