aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gleam/float.gleam13
-rw-r--r--src/gleam/int.gleam4
2 files changed, 9 insertions, 8 deletions
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: <https://www.erlang.org/doc/man/rand.html#uniform-0>
///
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: <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random>
///
@@ -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: <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random#getting_a_random_number_between_two_values>
+ //
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?
}