Techieindoor

Go – How to get the sine of the radian of number in go

Here, We will learn how to get the sine of the radian of number in go. We can get it by using Sin() function in math package in go golang.

Function prototype:

func Sin(x float64) float64

Return value:

Sin() function in math package returns 
the sine of the radian of number.

Example with code:

package main

import (
  "fmt"
  "math"
)

func main() {

  no := math.Sin(1.2)
  fmt.Println(no)

  no = math.Sin(-2.7)
  fmt.Println(no)

  no = math.Sin(0.0)
  fmt.Println(no)

  no = math.Sin(-2.9)
  fmt.Println(no)

  no = math.Sin(2)
  fmt.Println(no)
}

Output:

0.9320390859672264
-0.4273798802338298
0
-0.2392493292139824
0.9092974268256816

To learn more about golang, Please refer given below link:

https://www.techieindoor.com/go-lang-tutorial/

References:

https://golang.org/doc/
https://golang.org/pkg/
Exit mobile version