sin

expect fun sin(x: Double): Double(source)

Computes the sine of the angle x given in radians.

Special cases:

  • sin(NaN|+Inf|-Inf) is NaN

Since Kotlin

1.2

Samples

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

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

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

// special cases
println(sin(Double.NaN)) // NaN
println(sin(Double.POSITIVE_INFINITY)) // NaN
println(sin(Double.NEGATIVE_INFINITY)) // NaN 
   //sampleEnd
}

expect fun sin(x: Float): Float(source)

Computes the sine of the angle x given in radians.

Special cases:

  • sin(NaN|+Inf|-Inf) is NaN

Since Kotlin

1.2

Samples

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

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

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

// special cases
println(sin(Float.NaN)) // NaN
println(sin(Float.POSITIVE_INFINITY)) // NaN
println(sin(Float.NEGATIVE_INFINITY)) // NaN 
   //sampleEnd
}
actual inline fun sin(x: Double): Double(source)

Computes the sine of the angle x given in radians.

Special cases:

  • sin(NaN|+Inf|-Inf) is NaN

Since Kotlin

1.2

Samples

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

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

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

// special cases
println(sin(Double.NaN)) // NaN
println(sin(Double.POSITIVE_INFINITY)) // NaN
println(sin(Double.NEGATIVE_INFINITY)) // NaN 
   //sampleEnd
}

actual inline fun sin(x: Float): Float(source)

Computes the sine of the angle x given in radians.

Special cases:

  • sin(NaN|+Inf|-Inf) is NaN

Since Kotlin

1.2

Samples

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

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

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

// special cases
println(sin(Float.NaN)) // NaN
println(sin(Float.POSITIVE_INFINITY)) // NaN
println(sin(Float.NEGATIVE_INFINITY)) // NaN 
   //sampleEnd
}
actual inline fun sin(x: Double): Double(source)

Computes the sine of the angle x given in radians.

Special cases:

  • sin(NaN|+Inf|-Inf) is NaN

Since Kotlin

1.2

Samples

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

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

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

// special cases
println(sin(Double.NaN)) // NaN
println(sin(Double.POSITIVE_INFINITY)) // NaN
println(sin(Double.NEGATIVE_INFINITY)) // NaN 
   //sampleEnd
}

actual inline fun sin(x: Float): Float(source)

Computes the sine of the angle x given in radians.

Special cases:

  • sin(NaN|+Inf|-Inf) is NaN

Since Kotlin

1.2

Samples

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

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

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

// special cases
println(sin(Float.NaN)) // NaN
println(sin(Float.POSITIVE_INFINITY)) // NaN
println(sin(Float.NEGATIVE_INFINITY)) // NaN 
   //sampleEnd
}
actual external fun sin(x: Double): Double(source)

Computes the sine of the angle x given in radians.

Special cases:

  • sin(NaN|+Inf|-Inf) is NaN

Since Kotlin

1.3

Samples

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

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

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

// special cases
println(sin(Double.NaN)) // NaN
println(sin(Double.POSITIVE_INFINITY)) // NaN
println(sin(Double.NEGATIVE_INFINITY)) // NaN 
   //sampleEnd
}

actual external fun sin(x: Float): Float(source)

Computes the sine of the angle x given in radians.

Special cases:

  • sin(NaN|+Inf|-Inf) is NaN

Since Kotlin

1.3

Samples

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

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

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

// special cases
println(sin(Float.NaN)) // NaN
println(sin(Float.POSITIVE_INFINITY)) // NaN
println(sin(Float.NEGATIVE_INFINITY)) // NaN 
   //sampleEnd
}
actual fun sin(x: Double): Double(source)

Computes the sine of the angle x given in radians.

Special cases:

  • sin(NaN|+Inf|-Inf) is NaN

Since Kotlin

1.8

Samples

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

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

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

// special cases
println(sin(Double.NaN)) // NaN
println(sin(Double.POSITIVE_INFINITY)) // NaN
println(sin(Double.NEGATIVE_INFINITY)) // NaN 
   //sampleEnd
}

actual fun sin(x: Float): Float(source)

Computes the sine of the angle x given in radians.

Special cases:

  • sin(NaN|+Inf|-Inf) is NaN

Since Kotlin

1.8

Samples

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

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

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

// special cases
println(sin(Float.NaN)) // NaN
println(sin(Float.POSITIVE_INFINITY)) // NaN
println(sin(Float.NEGATIVE_INFINITY)) // NaN 
   //sampleEnd
}
actual fun sin(x: Double): Double(source)

Computes the sine of the angle x given in radians.

Special cases:

  • sin(NaN|+Inf|-Inf) is NaN

Since Kotlin

1.8

Samples

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

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

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

// special cases
println(sin(Double.NaN)) // NaN
println(sin(Double.POSITIVE_INFINITY)) // NaN
println(sin(Double.NEGATIVE_INFINITY)) // NaN 
   //sampleEnd
}

actual fun sin(x: Float): Float(source)

Computes the sine of the angle x given in radians.

Special cases:

  • sin(NaN|+Inf|-Inf) is NaN

Since Kotlin

1.8

Samples

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

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

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

// special cases
println(sin(Float.NaN)) // NaN
println(sin(Float.POSITIVE_INFINITY)) // NaN
println(sin(Float.NEGATIVE_INFINITY)) // NaN 
   //sampleEnd
}