Menu Close

Go – How to get the base-x exponential of y in go

Here, We will learn how to get the base-x exponential of y in go. We can get it by using Pow() function in math package in go golang.

Function prototype:

func Pow(x, y float64) float64

Return value:

Pow() function in math package returns 
the base-x exponential of y i.e x ** y.

Example with code:

package main

import (
  "fmt"
  "math"
)

func main() {

  no := math.Pow(3, 5)
  fmt.Println(no)

  no = math.Pow(2.3, 2)
  fmt.Println(no)

  no = math.Pow(-2.2, -10)
  fmt.Println(no)

  no = math.Pow(3, 0)
  fmt.Println(no)

}

Output:

243
5.289999999999999
0.00037650711858352683
1

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/
Posted in golang, math

Leave a Reply

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