Can anybody think of a way to put this into a batch file?
I thought it might be interesting to follow the instructions from the link. This is actually easier to do with a pencil and paper than with batch language but if the ancient Greeks could do it, why not us? Except for perfect squares, square roots are irrational numbers and any mechanical method will only give close approximations.
@echo off
setlocal enabledelayedexpansion
set count=0
set /p dend=Enter Number:
set num=%dend%
for /l %%i in (%dend%, -1, 1) do (
set /a sqr=%%i*%%i
if !sqr! leq %dend% (
set digit=%%i.
set root=%%i
goto out
)
)
:out
call set /a count=%%count%%+1
if %count% GTR 5 goto next
set /a dend=(%dend%-%sqr%)*100
set /a div=%root%*2
for /l %%i in (9,-1,0) do (
set /a sqr=%div%%%i*%%i
if !sqr! leq %dend% (
set root=%root%%%i
goto out
)
)
:next
set root=%root:~-5%
if %dend% neq 0 set digit=%digit%%root%
echo Square Root of %num% is %digit%
Precision is 5 decimals. The code can be tweaked if you require changes.
Note: This runs at glacial speed with large numbers.
Edit: I was typing this when you made your last post. Most script languages have a square root function which would put the above code to shame. Check out VBScript (installed with Windows), Python (requires download) or even the C language.
Good luck.