Standard library / math/big

big.Int.SetBytes()

Set nonnegative magnitude from big-endian bytes, independent of original sign. This method writes to the receiver (use a separate destination to preserve inputs when needed). Expected stdout: '258\n'.

Formal Syntax & Structure

go syntaxgo
func (z *Int) SetBytes(buf []byte) *Int

Parameters & Attributes

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

Return Value

*Int

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

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/big")
func main() {  fmt.Println(new(big.Int).SetBytes([]byte{1, 2}))}
Go Reference