Standard library / math/big

big.Float.GobDecode()

Decode gob bytes into a receiver; existing nonzero precision and rounding mode control rounding, otherwise restore encoded settings. This method writes to the receiver (use a separate destination to preserve inputs when needed). Expected stdout: '1.25 53\n'.

Formal Syntax & Structure

go syntaxgo
func (z *Float) GobDecode(buf []byte) error

Parameters & Attributes

NameTypeDescription
buf[]byteByte buffer or encoded data, as specified in the method contract.

Return Value

error

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

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/big")
func check(err error) {  if err != nil {    panic(err)  }}func main() {  x := big.NewFloat(1.25)  b, e := x.GobEncode()  check(e)  z := new(big.Float)  check(z.GobDecode(b))  fmt.Println(z, z.Prec())}
Go Reference