Menu Close

Go – How to return the arccosine of number in radians in go

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

The arccosine of number is defined as the inverse cosine function of number when -1≤x≤1.

Function prototype:

func Acos(no float64) float64

Return value:

Acos() function of math package returns 
the arccosine, in radians, of number.

Example with code:

package main

import (
  "fmt"
  "math"
)

func main() {

  fmt.Printf("%.2f\n", math.Acos(1))
	
  fmt.Printf("%.2f\n", math.Acos(0.5))
	
  fmt.Printf("%.2f\n", math.Acos(0.75))
	
}

Output:

0.00
1.05
0.72

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

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

References:

https://golang.org/doc/
https://golang.org/pkg/
Posted in golang, math

Leave a Reply

Your email address will not be published. Required fields are marked *