.acos()
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.
Contribute to Docs
- 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.
Learn Kotlin on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn Kotlin
Learn Kotlin, the expressive, open-source programming language developed by JetBrains.Beginner Friendly9 hours