Advertisement
IcarusLives

sqrt Function

Feb 18th, 2017
889
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.62 KB | None | 0 0
  1. ::--------------------------------------------------------------------------------------------------
  2. :: Square root a number
  3. ::
  4. :: call :sqrt 144
  5. :: call :sqrt 144 return_var
  6. ::
  7. ::--------------------------------------------------------------------------------------------------
  8. :sqrt
  9.     setlocal
  10.         set "s=%~1"
  11.         set /A "x=s/(11*1024)+40,x=(s/x+x)>>1,x=(s/x+x)>>1,x=(s/x+x)>>1,x=(s/x+x)>>1,x=(s/x+x)>>1,x+=(s-x*x)>>31
  12.     (endlocal
  13.         if "%~2" neq "" ( set %~2=%x% ) else echo %x%
  14.     )
  15. goto :eof
  16. ::--------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement