aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConnor Schembor <connor.schembor@rutgers.edu>2020-10-29 21:52:05 -0400
committerLouis Pilfold <louis@lpil.uk>2020-10-30 11:46:09 +0100
commit8e421527ad59a4bcea656ca1cdd6c643c99771c9 (patch)
tree2a613e75920bdf648eb336b7ba739ebb2984036b /src
parent6b2b12760686566bf4ca88008f06194788d32eb1 (diff)
downloadgleam_stdlib-8e421527ad59a4bcea656ca1cdd6c643c99771c9.tar.gz
gleam_stdlib-8e421527ad59a4bcea656ca1cdd6c643c99771c9.zip
Add to_float function for int module
Diffstat (limited to 'src')
-rw-r--r--src/gleam/int.gleam16
1 files changed, 16 insertions, 0 deletions
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