Revision: 1410 Author: jsuijs Date: Sat Oct 24 05:27:44 2009 Log: For Rob, a preliminary version of integer-based sqrt http://code.google.com/p/jallib/source/detail?r=1410
Added: /trunk/include/jal/sqrt.jal ======================================= --- /dev/null +++ /trunk/include/jal/sqrt.jal Sat Oct 24 05:27:44 2009 @@ -0,0 +1,31 @@ +-- sqrt.jal + +; http://www.azillionmonkeys.com/qed/sqroot.html +; +; xest ? (xest + y/xest) / 2 +; +; in 4 itteraties met de juiste preset (xest) wordt de sqrt van ieder (?) dword berekend (+/- 1) +; + + +function sqrt(sdword in invalue) return sword is + var dword xest + + if (invalue < 10_000) then + xest = 31 + elsif (invalue < 5_000_000) then + xest = 600 + elsif (invalue < 200_000_000) then + xest = 8000 + else + xest = 40000 + end if + + + for 4 loop + xest = (xest + invalue / xest) / 2 + end loop + + return sword(xest) + +end function --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jallib?hl=en -~----------~----~----~----~------~----~------~--~---
