Menu Close

Go – How to get the base-10 exponential of n in go

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

Function prototype:

func Pow10(n int) float64

Return value:

Pow10() function in math package returns 
the base-10 exponential of n i.e 10 ** n.

Example with code:

package main

import (
  "fmt"
  "math"
)

func main() {

  no := math.Pow10(3)
  fmt.Println(no)

  no = math.Pow10(5)
  fmt.Println(no)

  no = math.Pow10(-2)
  fmt.Println(no)

  no = math.Pow10(0)
  fmt.Println(no)

}

Output:

1000
100000
0.01
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 *