sin()
board40654449215 total contributions
Published Oct 27, 2023
Contribute to Docs
The math.sin()
method in Kotlin’s math
class is used to calculate the sine of an angle in radians.
Syntax
import kotlin.math.sin
val sineValue = sin(angle)
angle
: The angle in radians for which you want to calculate the sine.
The math.sin()
method returns a value of type Double
representing the sine of the input angle.
Example
This example shows how to use the math.sin()
method to calculate the sine of an angle:
import kotlin.math.*fun main() {val angle = PI / 6.0 // 30 degrees in radiansval sineValue = sin(angle)println("The sine of $angle radians is $sineValue.")}
This results in the following output:
The sine of 0.5235987755982989 radians is 0.49999999999999994.
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.