Skip to main content

Mojo function

random_float64

random_float64(min: Float64 = 0, max: Float64 = 1) -> Float64

Returns a random Float64 number from the given range [min, max).

Example:

from random import random_float64, seed

seed()
var rnd = random_float64(10.0, 20.0)
print(rnd)  # Random float between 10.0 and 20.0

Args:

  • min (Float64): The minimum number in the range (inclusive, default is 0.0).
  • max (Float64): The maximum number in the range (exclusive, default is 1.0).

Returns:

Float64: A random number sampled uniformly from [min, max).

Was this page helpful?