|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
11-29-2007 21:45
LSLEditor's llModPow doesn't work properly, I've created a hack that does an OK job of working around it but I don't think it is the correct solution. It seems to work but I haven't tested the boarder conditions. //llModPow is the current implementation of llModPow in LSLEditor //This function is recursive but i doubt it will recurse more then 1. integer ModPow(integer x, integer y, integer m) { if(!x) return 0; integer k = 1+llCeil(llLog(llAbs(x)) / 0.69314718055994530941723212145818);//ceil(log2(x)) integer w = 32; integer p = w / k; integer r = y / p; integer f = y % p; integer z = 1; if(r) z = ModPow(llModPow(x,p,m),r,m); if(f) z = (z * llModPow(x,f,m)) % m; return z; }
You can learn about how to implement this function here: http://www.cs.washington.edu/education/courses/csep590/06wi/http://www.cs.washington.edu/education/courses/csep590/06wi/lectures/Current results of running this: //Test Code default { state_entry() { integer x=3;integer y=0;integer m=5; for(; y < 64; y++) llOwnerSay(llList2CSV([x,y,m, ModPow(x,y,m), llModPow(x,y,m)])); } }
LSLEditor: 3, 0, 5, 1, 1 LSLEditor: 3, 1, 5, 3, 3 LSLEditor: 3, 2, 5, 4, 4 LSLEditor: 3, 3, 5, 2, 2 LSLEditor: 3, 4, 5, 1, 1 LSLEditor: 3, 5, 5, 3, 3 LSLEditor: 3, 6, 5, 4, 4 LSLEditor: 3, 7, 5, 2, 2 LSLEditor: 3, 8, 5, 1, 1 LSLEditor: 3, 9, 5, 3, 3 LSLEditor: 3, 10, 5, 4, 4 LSLEditor: 3, 11, 5, 2, 2 LSLEditor: 3, 12, 5, 1, 1 LSLEditor: 3, 13, 5, 3, 3 LSLEditor: 3, 14, 5, 4, 4 LSLEditor: 3, 15, 5, 2, 2 LSLEditor: 3, 16, 5, 1, 1 LSLEditor: 3, 17, 5, 3, 3 LSLEditor: 3, 18, 5, 4, 4 LSLEditor: 3, 19, 5, 2, 2 LSLEditor: 3, 20, 5, 1, -3 LSLEditor: 3, 21, 5, 3, -3 LSLEditor: 3, 22, 5, 4, -3 LSLEditor: 3, 23, 5, 2, -3 LSLEditor: 3, 24, 5, 1, -3 LSLEditor: 3, 25, 5, 3, -3 LSLEditor: 3, 26, 5, 4, -3 LSLEditor: 3, 27, 5, 2, -3 LSLEditor: 3, 28, 5, 1, -3 LSLEditor: 3, 29, 5, 3, -3 LSLEditor: 3, 30, 5, 4, -3 LSLEditor: 3, 31, 5, 2, -3 LSLEditor: 3, 32, 5, 1, -3 LSLEditor: 3, 33, 5, 3, -3 LSLEditor: 3, 34, 5, 4, -3 LSLEditor: 3, 35, 5, 2, -3 LSLEditor: 3, 36, 5, 1, -3 LSLEditor: 3, 37, 5, 3, -3 LSLEditor: 3, 38, 5, 4, -3 LSLEditor: 3, 39, 5, 2, -3 LSLEditor: 3, 40, 5, 1, -3 LSLEditor: 3, 41, 5, 3, -3 LSLEditor: 3, 42, 5, 4, -3 LSLEditor: 3, 43, 5, 2, -3 LSLEditor: 3, 44, 5, 1, -3 LSLEditor: 3, 45, 5, 3, -3 LSLEditor: 3, 46, 5, 4, -3 LSLEditor: 3, 47, 5, 2, -3 LSLEditor: 3, 48, 5, 1, -3 LSLEditor: 3, 49, 5, 3, -3 LSLEditor: 3, 50, 5, 4, -3 LSLEditor: 3, 51, 5, 2, -3 LSLEditor: 3, 52, 5, 1, -3 LSLEditor: 3, 53, 5, 3, -3 LSLEditor: 3, 54, 5, 4, -3 LSLEditor: 3, 55, 5, 2, -3 LSLEditor: 3, 56, 5, 1, -3 LSLEditor: 3, 57, 5, 3, -3 LSLEditor: 3, 58, 5, 4, -3 LSLEditor: 3, 59, 5, 2, -3 LSLEditor: 3, 60, 5, 1, -3 LSLEditor: 3, 61, 5, 3, -3 LSLEditor: 3, 62, 5, 4, -3 LSLEditor: 3, 63, 5, 2, -3 SL: 3, 0, 5, 1, 1 SL: 3, 1, 5, 3, 3 SL: 3, 2, 5, 4, 4 SL: 3, 3, 5, 2, 2 SL: 3, 4, 5, 1, 1 SL: 3, 5, 5, 3, 3 SL: 3, 6, 5, 4, 4 SL: 3, 7,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th is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|