Standard library / math/big

big.Float.Copy()

Copy value, precision, rounding mode and accuracy into the receiver, unlike Set which respects destination settings. This method writes to the receiver (use a separate destination to preserve inputs when needed). Expected stdout: '1.25 20 ToZero\n'.

Formal Syntax & Structure

go syntaxgo
func (z *Float) Copy(x *Float) *Float

Parameters & Attributes

NameTypeDescription
x*FloatNumeric operand supplied to this method.

Return Value

*Float

Returns the result described above; see the example for the observed behavior.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/big")
func main() {  x := big.NewFloat(1.25).SetPrec(20).SetMode(big.ToZero)  z := new(big.Float).Copy(x)  fmt.Println(z, z.Prec(), z.Mode())}
Go Reference