aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConnor Schembor <cschembor96@gmail.com>2020-08-25 20:29:57 -0400
committerLouis Pilfold <louis@lpil.uk>2020-08-27 13:55:55 +0100
commit41d2256cb18cfb657ab6a0eaccb4f315e390b618 (patch)
treef11eb8ad3a932f03168557a97ff56d56e5eae3e7 /src
parente9817a0f6dd9b77c048b0a702e6b897dd95bebf8 (diff)
downloadgleam_stdlib-41d2256cb18cfb657ab6a0eaccb4f315e390b618.tar.gz
gleam_stdlib-41d2256cb18cfb657ab6a0eaccb4f315e390b618.zip
Add power function for floats
This adds a function for evaluating exponents for floats. Calls the erlang math module function
Diffstat (limited to 'src')
-rw-r--r--src/gleam/float.gleam14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/gleam/float.gleam b/src/gleam/float.gleam
index c85903f..3767113 100644
--- a/src/gleam/float.gleam
+++ b/src/gleam/float.gleam
@@ -128,3 +128,17 @@ pub external fn truncate(Float) -> Int =
///
pub external fn absolute_value(Float) -> Float =
"erlang" "abs"
+
+/// Returns the results of the base being raised to the power of the
+/// exponent, as a float.
+///
+/// ## Examples
+///
+/// > power(2.0, 2.0)
+/// 4.0
+///
+/// > power(8.0, 1.5)
+/// 64.0
+///
+pub external fn power(base: Float, exponent: Float) -> Float =
+ "math" "pow"