Due to a current lack of square root code around massassi (as far as I can tell). I decided to give you my temporary version until my math teacher can get me the actual formula.
Feel free to use the code however you see fit, but please credit me somehow.
[edit] Just so you know, I put in the call message so that it would be easilly accessed by ANYTHING (you can call it from anywhere). [/edit]
[edit2] I forgot to mention, it works for roughly 4 decimals [/edit2]
Code:
# Jedi Knight Cog Script
#
# square_root.cog
#
# Finds the Square root of a number, rootme.
#
# SG-fan
#
symbols
message activated
surface button
flex a local
flex b local
flex answer local
flex rootme //number to be rooted
end
code
activated:
call sqrt;
return;
sqrt:
for(a=0; rootme-a*a>=0; a=a+1)
{}
if(rootme-a*a>rootme-(a-1)*(a-1))
a=a-1;
b=rootme-a*a;
answer=(a+(b/(2*a)))-(((b/(2*a))*(b/(2*a)))/(2*(a+(b/(2*a)))));
printflex(answer);
return;
endFeel free to use the code however you see fit, but please credit me somehow.
[edit] Just so you know, I put in the call message so that it would be easilly accessed by ANYTHING (you can call it from anywhere). [/edit]
[edit2] I forgot to mention, it works for roughly 4 decimals [/edit2]
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Jack: "Why not!"