Sin()
web11612516591 total contribution
Published Jun 21, 2023
Contribute to Docs
The Sin()
function in Go is used to calculate the sine of an angle. It returns the sine value of the specified angle given in radians.
Syntax
The syntax for using the Sin()
function in Go is as follows:
import "math"
result := math.Sin(angle)
Where result
is the sine of angle
.
Example
The following example demonstrates a basic implementation of the Sin()
function:
package mainimport ("fmt""math")func main() {angle := 45.0sineValue := math.Sin(angle * math.Pi / 180) // Convert 45(in degrees) to radiansfmt.Println("Sine of", angle, "degrees is", sineValue)}
This code will print the following output:
Sine of 45 degrees is 0.70710678118
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.