Standard library / math/big

big.Float.SetFloat64()

Set from an already rounded binary64 value, not the original decimal literal. NaN panics with ErrNaN. This method writes to the receiver (use a separate destination to preserve inputs when needed). Expected stdout: '0.125 53\n'.

Formal Syntax & Structure

go syntaxgo
func (z *Float) SetFloat64(x float64) *Float

Parameters & Attributes

NameTypeDescription
xfloat64Numeric 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() {  z := new(big.Float).SetFloat64(0.125)  fmt.Println(z, z.Prec())}
Go Reference