Spec-Zone.ru › Kotlin 2

asin

kotlin-stdlib/kotlin.math/asin

Требования к платформе и версии: Common (1.2), Wasm-JS (1.8), Wasm-WASI (1.8)

expect fun asin(x: Double): Double

Вычисляет арксинус значения x; возвращаемое значение — угол в диапазоне от -PI/2 до PI/2 радиан.

Особые случаи:

  • asin(x) равно NaN, если abs(x) > 1 или x равно NaN

Примеры

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val epsilon = 1e-10

println(asin(0.0)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// asin(1.0) = π/2
println("(asin(1.0) - PI / 2).absoluteValue < epsilon is ${(asin(1.0) - PI / 2).absoluteValue < epsilon}") // true
// asin(-1.0) = -π/2
println("(asin(-1.0) - (-PI / 2)).absoluteValue < epsilon is ${(asin(-1.0) - (-PI / 2)).absoluteValue < epsilon}") // true
// asin(sin(x)) = x
println("(asin(sin(0.123)) - 0.123).absoluteValue < epsilon is ${(asin(sin(0.123)) - 0.123).absoluteValue < epsilon}") // true

// special cases
println(asin(Double.NaN)) // NaN
println(asin(1.1)) // NaN
println(asin(-2.0)) // NaN 
   //sampleEnd
}

expect fun asin(x: Float): Float

Вычисляет арксинус значения x; возвращаемое значение — угол в диапазоне от -PI/2 до PI/2 радиан.

Особые случаи:

  • asin(x) равно NaN, если abs(x) > 1 или x равно NaN

Примеры

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val epsilon = 1e-6f

println(asin(0.0f)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// asin(1.0) = π/2
println("(asin(1.0f) - PI.toFloat() / 2).absoluteValue < epsilon is ${(asin(1.0f) - PI.toFloat() / 2).absoluteValue < epsilon}") // true
// asin(-1.0) = -π/2
println("(asin(-1.0f) - (-PI.toFloat() / 2)).absoluteValue < epsilon is ${(asin(-1.0f) - (-PI.toFloat() / 2)).absoluteValue < epsilon}") // true
// asin(sin(x)) = x
println("(asin(sin(0.25f)) - 0.25f).absoluteValue < epsilon is ${(asin(sin(0.25f)) - 0.25f).absoluteValue < epsilon}") // true

// special cases
println(asin(Float.NaN)) // NaN
println(asin(1.1f)) // NaN
println(asin(-2.0f)) // NaN 
   //sampleEnd
}

Требования к платформе и версии: JS (1.2), JVM (1.2)

actual inline fun asin(x: Double): Double

Вычисляет арксинус значения x; возвращаемое значение — угол в диапазоне от -PI/2 до PI/2 радиан.

Особые случаи:

  • asin(x) равно NaN, если abs(x) > 1 или x равно NaN

Примеры

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val epsilon = 1e-10

println(asin(0.0)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// asin(1.0) = π/2
println("(asin(1.0) - PI / 2).absoluteValue < epsilon is ${(asin(1.0) - PI / 2).absoluteValue < epsilon}") // true
// asin(-1.0) = -π/2
println("(asin(-1.0) - (-PI / 2)).absoluteValue < epsilon is ${(asin(-1.0) - (-PI / 2)).absoluteValue < epsilon}") // true
// asin(sin(x)) = x
println("(asin(sin(0.123)) - 0.123).absoluteValue < epsilon is ${(asin(sin(0.123)) - 0.123).absoluteValue < epsilon}") // true

// special cases
println(asin(Double.NaN)) // NaN
println(asin(1.1)) // NaN
println(asin(-2.0)) // NaN 
   //sampleEnd
}

actual inline fun asin(x: Float): Float

Вычисляет арксинус значения x; возвращаемое значение — угол в диапазоне от -PI/2 до PI/2 радиан.

Особые случаи:

  • asin(x) равно NaN, если abs(x) > 1 или x равно NaN

Примеры

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val epsilon = 1e-6f

println(asin(0.0f)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// asin(1.0) = π/2
println("(asin(1.0f) - PI.toFloat() / 2).absoluteValue < epsilon is ${(asin(1.0f) - PI.toFloat() / 2).absoluteValue < epsilon}") // true
// asin(-1.0) = -π/2
println("(asin(-1.0f) - (-PI.toFloat() / 2)).absoluteValue < epsilon is ${(asin(-1.0f) - (-PI.toFloat() / 2)).absoluteValue < epsilon}") // true
// asin(sin(x)) = x
println("(asin(sin(0.25f)) - 0.25f).absoluteValue < epsilon is ${(asin(sin(0.25f)) - 0.25f).absoluteValue < epsilon}") // true

// special cases
println(asin(Float.NaN)) // NaN
println(asin(1.1f)) // NaN
println(asin(-2.0f)) // NaN 
   //sampleEnd
}

Требования к платформе и версии: Native (1.3)

actual external fun asin(x: Double): Double

Вычисляет арксинус значения x; возвращаемое значение — угол в диапазоне от -PI/2 до PI/2 радиан.

Особые случаи:

  • asin(x) равно NaN, если abs(x) > 1 или x равно NaN

Примеры

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val epsilon = 1e-10

println(asin(0.0)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// asin(1.0) = π/2
println("(asin(1.0) - PI / 2).absoluteValue < epsilon is ${(asin(1.0) - PI / 2).absoluteValue < epsilon}") // true
// asin(-1.0) = -π/2
println("(asin(-1.0) - (-PI / 2)).absoluteValue < epsilon is ${(asin(-1.0) - (-PI / 2)).absoluteValue < epsilon}") // true
// asin(sin(x)) = x
println("(asin(sin(0.123)) - 0.123).absoluteValue < epsilon is ${(asin(sin(0.123)) - 0.123).absoluteValue < epsilon}") // true

// special cases
println(asin(Double.NaN)) // NaN
println(asin(1.1)) // NaN
println(asin(-2.0)) // NaN 
   //sampleEnd
}

actual external fun asin(x: Float): Float

Вычисляет арксинус значения x; возвращаемое значение — угол в диапазоне от -PI/2 до PI/2 радиан.

Особые случаи:

  • asin(x) равно NaN, если abs(x) > 1 или x равно NaN

Примеры

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val epsilon = 1e-6f

println(asin(0.0f)) // 0.0
// Results may not be exact, so we're only checking that they are within epsilon from the expected value
// asin(1.0) = π/2
println("(asin(1.0f) - PI.toFloat() / 2).absoluteValue < epsilon is ${(asin(1.0f) - PI.toFloat() / 2).absoluteValue < epsilon}") // true
// asin(-1.0) = -π/2
println("(asin(-1.0f) - (-PI.toFloat() / 2)).absoluteValue < epsilon is ${(asin(-1.0f) - (-PI.toFloat() / 2)).absoluteValue < epsilon}") // true
// asin(sin(x)) = x
println("(asin(sin(0.25f)) - 0.25f).absoluteValue < epsilon is ${(asin(sin(0.25f)) - 0.25f).absoluteValue < epsilon}") // true

// special cases
println(asin(Float.NaN)) // NaN
println(asin(1.1f)) // NaN
println(asin(-2.0f)) // NaN 
   //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.math/asin.html

Spec-Zone.ru

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