user7039610
user7039610

Reputation:

How to compute the square root of a number in ATS?

I know that one can use the sqrt function in libc/math for doing it:

staload
Math =
"libats/libc/SATS/math.sats"

val sqrt2 = $Math.sqrt(2.0)
val sqrt3 = $Math.sqrt(3.0)

I am looking for a direct implementation of sqrt in ATS if possible.

Upvotes: 3

Views: 126

Answers (1)

Arets Paeglis
Arets Paeglis

Reputation: 4006

See this snippet for a basic implementation of the square root using the Newton-Raphson method.

Upvotes: 1

Related Questions