Standard library / math
math.Copysign()
Magnitude of first operand with sign bit of second operand, including signed zero. Expected stdout: '-3\n'.
Formal Syntax & Structure
go syntaxgo
func Copysign(f, sign float64) float64Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| f | float64 | Input floating-point value. |
| sign | float64 | Sign selector. |
Return Value
float64
Magnitude of first operand with sign bit of second operand, including signed zero.
Working Example
Example Snippetgo
package main
import ( "fmt" "math")
func main() { fmt.Println(math.Copysign(3, -1))}