From 8e421527ad59a4bcea656ca1cdd6c643c99771c9 Mon Sep 17 00:00:00 2001 From: Connor Schembor Date: Thu, 29 Oct 2020 21:52:05 -0400 Subject: Add to_float function for int module --- src/gleam/int.gleam | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src') diff --git a/src/gleam/int.gleam b/src/gleam/int.gleam index 2dc4f46..f717eaa 100644 --- a/src/gleam/int.gleam +++ b/src/gleam/int.gleam @@ -42,6 +42,22 @@ pub external fn to_string(Int) -> String = pub external fn to_base_string(Int, Int) -> String = "erlang" "integer_to_binary" +/// Takes an int and returns its value as a float +/// +/// ## Examples +/// +/// > to_float(5) +/// 5. +/// +/// > to_float(0) +/// 0. +/// +/// > to_float(-3) +/// -3. +/// +pub external fn to_float(a: Int) -> Float = + "erlang" "float" + /// Compares two ints, returning an order. /// /// ## Examples -- cgit v1.2.3