Copy the Sign of Given Number in Golang
Go language provides inbuilt support for basic constants and mathematical functions to perform operations on the numbers with the help of the math package. You are allowed to copy the sign of the specified number with the help of Copysign() function provided by the math package. So, you need to add a math package in your program with the help of the import keyword to access the Copysign() function.
func Copysign(a, b float64) float64
Here, this function returns a value with the magnitude of a and the sign of b.
Result 1: -2.0 Result 2: 8.0 Result 3: -67.0
-3.0 + 4.0 = 1.0