From 41d2256cb18cfb657ab6a0eaccb4f315e390b618 Mon Sep 17 00:00:00 2001 From: Connor Schembor Date: Tue, 25 Aug 2020 20:29:57 -0400 Subject: Add power function for floats This adds a function for evaluating exponents for floats. Calls the erlang math module function --- src/gleam/float.gleam | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') 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" -- cgit v1.2.3