• Returns a real in range [lowBound, highBound) that is: inclusive, exclusive. Bounds may be negative, but must be lowBound <= highBound. When lowBound==highBound, always returns that number.

    Example (Lua):

    SetRandomSeed(1229611)
    string.format("%.16f", GetRandomReal(0, 0.002)) == "0.00"
    SetRandomSeed(1229611)
    string.format("%.16f", GetRandomReal(-0.002, 0)) == "-0.002"

    Parameters

    • lowBound: number
    • highBound: number

    Returns number

    Note

    Desyncs! The random number generator is a global, shared resource. Do not change its state in local blocks asynchronously.

    Note

    Undefined behavior when lowBound > highBound. Test code:

    -- Set seed to zero and then generate and print a random real
    function testRReal(low, high) SetRandomSeed(0); return string.format("%.16f", GetRandomReal(low,high)) end
    testRReal(-42, 42) == "-4.0800933837890625"
    testRReal(42, -42) == "79.9199066162109375"

    Note

    See: GetRandomInt, SetRandomSeed.

Generated using TypeDoc