W3cubDocs

/Kotlin

nextDouble

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
open fun nextDouble(): Double
fun nextDouble(): Double

Gets the next random Double value uniformly distributed between 0 (inclusive) and 1 (exclusive).

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
open fun nextDouble(until: Double): Double
fun nextDouble(until: Double): Double

Gets the next random non-negative Double from the random number generator less than the specified until bound.

Generates a Double random value uniformly distributed between 0 (inclusive) and until (exclusive).

Exceptions

IllegalArgumentException - if until is negative or zero.

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
open fun nextDouble(from: Double, until: Double): Double
fun nextDouble(from: Double, until: Double): Double

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

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

from and until must be finite otherwise the behavior is unspecified.

Exceptions

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

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.random/-random/next-double.html