How do I take the square root of a number in Elixir? There doesn't seem to be a Math
module or anything, and there is no function like sqrt()
.
Elixir compiles to BEAM, which makes it compatible with Erlang modules. As you said, :math.sqrt(x)
is essentially running Erlang code.
Hah. Found it. You take the square root like this:
:math.sqrt(x)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.