Difference between revisions of "Talk:Days in Month"

From Second Life Wiki
Jump to navigation Jump to search
m
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
:The current code is already doing that. It's the bit operator portial behind the return.
: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 & 1) gives 1 when it's an uneven month and 0 when it's an even month.  
:(month > 6) gives 1 when it's a month after June and 0 otherwise.
:(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.
: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)
: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)