From 1217a1fe1a13cecc347251456f5beb972474cb80 Mon Sep 17 00:00:00 2001 From: inoas Date: Tue, 12 Apr 2022 00:21:08 +0200 Subject: comments --- src/gleam/float.gleam | 13 +++++++------ src/gleam/int.gleam | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gleam/float.gleam b/src/gleam/float.gleam index 6f19b13..1b8220b 100644 --- a/src/gleam/float.gleam +++ b/src/gleam/float.gleam @@ -329,8 +329,8 @@ pub fn random_uniform() -> Float { } if erlang { - // Returns a random float uniformly distributed in the value range - // 0.0 =< X < 1.0 and updates the state in the process dictionary. + /// Returns a random float uniformly distributed in the value range + /// 0.0 =< X < 1.0 and updates the state in the process dictionary. /// See: /// external fn do_random_uniform() -> Float = @@ -338,10 +338,10 @@ if erlang { } if javascript { - // with round-to-nearest-even behavior, the ranges claimed for the functions below - // (excluding the one for Math.random() itself) aren't exact. - // If extremely large bounds are chosen (2^53 or higher), - // it's possible in extremely rare cases to calculate the usually-excluded upper bound. + /// With round-to-nearest-even behavior, the ranges claimed for the functions below + /// (excluding the one for Math.random() itself) aren't exact. + /// If extremely large bounds are chosen (2^53 or higher), + /// it's possible in extremely rare cases to calculate the usually-excluded upper bound. /// Note that as numbers in JavaScript are IEEE 754 floating point numbers /// See: /// @@ -354,5 +354,6 @@ pub fn random_between(min: Float, max: Float) -> Float { // return Math.floor(Math.random() * (max - min + 1) + min); // The maximum is/should-be exclusive // ``` // See: + // random_uniform() *. { max -. min } +. min } diff --git a/src/gleam/int.gleam b/src/gleam/int.gleam index 418d4fb..c255dd0 100644 --- a/src/gleam/int.gleam +++ b/src/gleam/int.gleam @@ -391,7 +391,7 @@ pub fn random_below(max: Int) -> Int { float.random_uniform() *. to_float(max) |> float.floor() |> float.round() - // Does `float.round() `affect random distribution uniformity? + // TODO: Does `float.round() `affect random distribution uniformity? } pub fn random_between(min: Int, max: Int) -> Int { @@ -404,5 +404,5 @@ pub fn random_between(min: Int, max: Int) -> Int { float.random_between(to_float(min), to_float(max)) |> float.floor() |> float.round() - // Does float.round() affect random distribution uniformity? + // TODO: Does float.round() affect random distribution uniformity? } -- cgit v1.2.3