I noticed the hard-coded "powf" function doesn't have support for negative-base decimal exponents. I couldn't see what algorithm the code uses (is it implied in a math library?) so I assume it uses one similar to mine, minus the aforementioned support. I added that on later. Here's the script version of it:
You can see, if it attempts to take the square root of a negative number, it pretends that that's okay and then "concat"s the imaginary unit "i" to the end of the result (so the user can have discretion in whether to use it).
- Have "scriptcontext" be more dynamic, based on whether you're in multiplayer (i.e., allow a set of contexts that are in force while connected to a server, and a different set in force when you're not).
- Also, allow idents to be removed from given security contexts, in-game, based on user preference (Yes, I know, it defeats the purpose of "sealcontexts," but I like having it more loosely sealed, or at least "openable" by the user).
[SELECT ALL] Code:
alias powdec [if (=f $arg2) [result 1] [
if (<f $arg2) [arg2 = (absval $arg2); negadec = 1] [negadec = 0]
powset = (concat 1 $arg1 0 1); powfcount = 0
while [(&& (&& (!=f (at $powset) $arg2) (!=f (at $powset 2) $arg2)) (<= $powfcount 30))] [
if (>f $arg2 (average (at $powset) (at $powset 2))) [
powset = (concat (at $powset) (at $powset 1) (average (at $powset) (at $powset 2)) (sqrt (*f (at $powset 1) (at $powset 3))))] [
if (<f $arg2 (average (at $powset) (at $powset 2))) [
powset = (concat (average (at $powset) (at $powset 2)) (sqrt (*f (at $powset 1) (at $powset 3))) (at $powset 2) (at $powset 3))] [
powset = (concat (average (at $powset) (at $powset 2)) (sqrt (*f (at $powset 1) (at $powset 3))))]]
+= powfcount 1]
if (<f $arg1) [if $negadec [result (concat (divf 1 (at $powset 1)) i)] [result (concat (at $powset 1) i)]] [
if $negadec [result (divf 1 (at $powset 1))] [result (at $powset 1)]]]] // Handles exponents between -1 and 1
// powdec (any base) (decimal exponent between -1 and 1)
alias powf [concat (*f (pow $arg1 (+ $arg2)) (powdec $arg1 (modf $arg2 1))) (at (powdec $arg1 (modf $arg2 1)) 1)]
- Have "scriptcontext" be more dynamic, based on whether you're in multiplayer (i.e., allow a set of contexts that are in force while connected to a server, and a different set in force when you're not).
- Also, allow idents to be removed from given security contexts, in-game, based on user preference (Yes, I know, it defeats the purpose of "sealcontexts," but I like having it more loosely sealed, or at least "openable" by the user).