Sin()
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
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 Go 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 Go
Learn how to use Go (Golang), an open-source programming language supported by Google!Beginner Friendly6 hours