# 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

+5.2k Golang : Get current, epoch time and display by year, month and day

+1.7k Golang : Selection sort example

+6.7k Golang : Get checkbox or extract multipart form data value example

+1k Golang : Scan forex opportunities by Bollinger bands

878 Golang : How to setup a disk space used monitoring service with Telegram bot

+14k Golang : Storing cookies in http.CookieJar example

+1k Golang : How to transmit update file to client by HTTP request example

+3.2k Golang : Extract part of string with regular expression

+13.5k Golang : For loop continue,break and range

+2.4k Golang : Generate random Chinese, Japanese, Korean and other runes

+2.2k Linux/Unix : Commands that you need to be careful about

+3.5k Golang : Meaning of omitempty in struct's field tag