W3cubDocs

/Kotlin

nextUInt

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
@ExperimentalUnsignedTypes fun Random.nextUInt(): UInt

Gets the next random UInt from the random number generator.

Generates a UInt random value uniformly distributed between UInt.MIN_VALUE and UInt.MAX_VALUE (inclusive).

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
@ExperimentalUnsignedTypes fun Random.nextUInt(
    until: UInt
): UInt

Gets the next random UInt from the random number generator less than the specified until bound.

Generates a UInt random value uniformly distributed between 0 (inclusive) and the specified until bound (exclusive).

Exceptions

IllegalArgumentException - if until is zero.

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
@ExperimentalUnsignedTypes fun Random.nextUInt(
    from: UInt, 
    until: UInt
): UInt

Gets the next random UInt from the random number generator in the specified range.

Generates a UInt random value uniformly distributed between the specified from (inclusive) and until (exclusive) bounds.

Exceptions

IllegalArgumentException - if from is greater than or equal to until.

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
@ExperimentalUnsignedTypes fun Random.nextUInt(
    range: UIntRange
): UInt

Gets the next random UInt from the random number generator in the specified range.

Generates a UInt random value uniformly distributed in the specified range: from range.start inclusive to range.endInclusive inclusive.

Exceptions

IllegalArgumentException - if range is empty.

© 2010–2019 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.random/next-u-int.html