.acos()
board40654449215 total contributions
Published Oct 17, 2023
Contribute to Docs
The .acos()
method in Kotlin’s math
class is used to calculate the arccosine of a given value, returning the corresponding angle in radians.
Syntax
import kotlin.math.*
val angle = acos(value)
value
: The given value to be used in the arccosine calculation. The value should be in the range -1
to 1
.
The .acos()
method returns a value of type double
representing the angle in radians. The result will be in the range 0
to PI
.
Example
This example shows how to use the acos()
method to calculate the arccosine of a value:
import kotlin.math.*fun main() {val value = 0.5val angle = acos(value)println("The arccosine of $value is $angle radians.")}
The output of this code will be:
The arccosine of 0.5 is 1.0471975511965979 radians.
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.