Spec-Zone.ru › Kotlin 2

nextFloat

kotlin-stdlib/kotlin.random/Random/nextFloat

Версия Kotlin: 1.3

open fun nextFloat(): Float

Возвращает следующее случайное значение Float, равномерно распределённое в диапазоне от 0 (включительно) до 1 (не включительно).

Примеры

import kotlin.math.sin
import kotlin.random.Random
import kotlin.test.assertTrue

fun main() { 
   //sampleStart 
   if (Random.nextFloat() <= 0.3) {
    println("There was 30% possibility of rainy weather today and it is raining.")
} else {
    println("There was 70% possibility of sunny weather today and the sun is shining.")
} 
   //sampleEnd
}

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

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API