# 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

+8.8k Golang : concatenate(combine) strings

+1.9k Golang : Find network service name from given port and protocol

+2.7k Findstr command the Grep equivalent for Windows

+4.8k Golang : Verify token from Google Authenticator App

+4.1k Golang : Read file with ioutil

+3k Golang : Get UDP client IP address and differentiate clients by port number

454 Golang : Configure Apache and NGINX to access your Go service example

+5.8k Golang : Calculate percentage change of two values

+8.1k Golang : Padding data for encryption and un-padding data for decryption

+2.3k Golang : Convert spaces to tabs and back to spaces example

+3.8k Golang : zlib compress file example

+3k Golang : Generate random elements without repetition or duplicate