Learn and Learn

Learn And Learn - great place for tutorials, references and how-to

GoLang – Hypot() Function – Examples & Explanation

Hypot() function is used to find the Sqrt(p*p + q*q) , taking care to avoid unnecessary overflow and underflow. The standard math package of Go programming language has Hypot() function.

Syntax of Hypot() Function in Go Programming

The syntax of Hypot() function in Go Language is:

Note: float64 is a data type in Go language which has IEEE-754 64-bit floating-point numbers.
Special cases are:
Hypot(±Inf, q) = +Inf
Hypot(p, ±Inf) = +Inf
Hypot(NaN, q) = NaN
Hypot(p, NaN) = NaN

 

Parameters of Hypot() Function in Go Programming

x – Where p , q is any Valid float64 Input value. These parameters are required.

 

Error Handling

If the p or q parameter is not a number (numeric value) Hypot() function returns an error .
If there is no argument (p or q – input value) passes to the function, then the compiler will produce an error.

 

Return Value of Hypot() Function in Go

Hypot() function will return Sqrt(p*p + q*q) , taking care to avoid unnecessary overflow and underflow.

 

GoLang Hypot() Function Example 1


Output:
7.615773105863909

 

GoLang Hypot() Function Example 2


Output:
11.180339887498947

 

GoLang Hypot() Function Example 3


Output:
76.05918747922568

 

LearnAndLearn.com © 2018 - All rights reserved