Here is a solution using Newton's method to calculate a square root:
when HTTP_REQUEST {
set input [URI::query [HTTP::uri] "input"]
if { ([HTTP::path] equals "/sqrt") && ($input ne "") } {
if { $input == 0 } {
set sqrt 0
} else {
set x [expr {abs($input)}]
while { 1 } {
set y [expr (($x+($input/$x))/2)]
if { [expr (abs($x-$y))] < 0.01 } break
set x $y
}
set sqrt $y
}
HTTP::respond 200 content "The square root of $input is $sqrt"
}
}
http://test-http-virtual/sqrt?input=144 => "The square root of 144 is 12"
http://test-http-virtual/sqrt?input=225.25 => "The square root of 225.25 is 15.0083321641"
http://test-http-virtual/sqrt?input=67108864.0 => "The square root of 67108864.09 is 8192.00000549"
Hope that helps,
George