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) float64

Parameters & Attributes

NameTypeDescription
ffloat64Input floating-point value.
signfloat64Sign 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))}
Go Reference