# Golang : Math pow(the power of x^y) example

No programming language will be complete without `the power of`

math function. This tutorial is a simple example on how to use `math.Pow()`

function.

In Math

2^5 = 2x2x2x2x2 =32In Golang

Math.pow(2, 5)

In code :

```
package main
import (
"fmt"
"math"
)
func main() {
result := math.Pow(2, 5)
fmt.Println(" 2 power of 5 is : ", result)
x := 10.5
y := 5
floatResult := math.Pow(x, float64(y)) //type cast int to float64
fmt.Printf(" %.02f power of %d is : %.02f \n", x, y, floatResult)
}
```

2 power of 5 is : 32

10.50 power of 5 is : 127628.16

#### Affiliate :

#### Hire Golang Developers

Tags : golang math-pow power-of

##### By Adam Ng

IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.

#### Advertisement

#### Tutorials

+1.7k Golang : Display advertisement images or strings on random order

+1.8k Golang : The Tao of importing package

+2.3k Fix fatal error: evacuation not done in time problem

+1.9k Golang : Command line ticker to show work in progress

+15.6k error: trying to remove "yum", which is protected

+17.7k Golang : How to get struct field and value by name

+2.7k Golang : Handle or parse date string with Z suffix(RFC3339) example

+3.3k Golang : How to check if a file is hidden?

+1.8k Golang : Denco multiplexer example

+2.1k Golang : Inject/embed Javascript before sending out to browser example

+8.1k Golang : Get file permission

+2.8k Golang : Get month name from date example