This commit is contained in:
Andreas Rumpf 2017-10-30 14:45:57 +01:00
commit b14cc1e3b2
8 changed files with 65 additions and 38 deletions

View file

@ -93,7 +93,7 @@ proc random*(max: float): float {.benign.} =
let u = (0x3FFu64 shl 52u64) or (x shr 12u64)
result = (cast[float](u) - 1.0) * max
proc random*[T](x: Slice[T, T]): T =
proc random*[T](x: HSlice[T, T]): T =
## For a slice `a .. b` returns a value in the range `a .. b-1`.
result = T(random(x.b - x.a)) + x.a