×

Golang Tutorial

Golang Reference

Golang Programs

Golang Practice

Golang Miscellaneous

Golang math.SqrtPhi Constant with Examples

Golang | math.SqrtPhi Constant: Here, we are going to learn about the SqrtPhi constant of the math package with its usages, syntax, and examples.
Submitted by IncludeHelp, on August 25, 2021

math.SqrtPhi Constant

The SqrtPhi constant is an inbuilt constant of the math package which is used to get the square root of the mathematical constant φ (Golden Ratio), approximately equal to 1.2720196495.

Syntax

float64 math.SqrtPhi

Parameters

  • None

Return Value

The return type of math.SqrtPhi constant is float64, it returns the square root of the mathematical constant φ (Golden Ratio).

Example 1

// Golang program to demonstrate the
// example of math.SqrtPhi Constant

package main

import (
	"fmt"
	"math"
)

func main() {
	fmt.Printf("Type of math.SqrtPhi is %T\n", math.SqrtPhi)
	fmt.Println("Value of math.SqrtPhi:", math.SqrtPhi)
}

Output:

Type of math.SqrtPhi is float64
Value of math.SqrtPhi: 1.272019649514069

Explanation:

In the above program, we imported the math package to use the math.SqrtPhi constant, then printed the type and value of the math.SqrtPhi constant.

Example 2

// Golang program to demonstrate the
// example of math.SqrtPhi Constant

package main

import (
	"fmt"
	"math"
)

// creating function to
// return the value of SqrtPhi.
func getSqrtPhi() float64 {
	return math.SqrtPhi
}

func main() {
	fmt.Println("Value of math.SqrtPhi:", getSqrtPhi())
}

Output:

Value of math.SqrtPhi: 1.272019649514069

Golang math Package Constants and Functions »




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.