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

Tags : golang math-pow power-of

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

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

+3.3k Golang : Display a text file line by line with line number example

+2.9k Web : How to see your website from different countries?

+1.8k Google : Block or disable caching of your website content

+7.9k Golang : Get IP addresses of a domain name

+1.6k Gogland : Datasource explorer

+12k Golang : All update packages with go get command

+2.6k Golang : Build and compile multiple source files

+5.7k Javascript : Prompt confirmation before exit

+15.2k Golang : How to split or chunking a file to smaller pieces?

+3.1k Golang : Concatenate (combine) buffer data example

+1.2k Golang : Find the length of big.Int variable example

+1.9k Golang : Reclaim memory occupied by make() example