BuringStraw

BuringStraw

F# bigint型の範囲内のランダムな数

let rnd x y =
    let r = Random()
    let mutable res = 0I
    let mutable first = true

    while not first && not (res >= x && res <= y) do
        first <- false
        let length = BigInteger.Log(y, 2) |> Math.Ceiling
        let numBytes = length / 8.0 |> Math.Ceiling |> Convert.ToInt32
        let data: byte[] = Array.zeroCreate numBytes
        r.NextBytes(data)
        res <- new BigInteger(data)

    res
読み込み中...
文章は、創作者によって署名され、ブロックチェーンに安全に保存されています。