Standard library / math/big

big.Int.SetBits()

Interpret little-endian machine words as unsigned magnitude, sharing storage with the argument. Low-level API; prefer SetBytes for portable data. This method writes to the receiver (use a separate destination to preserve inputs when needed). Expected stdout: '42\n'.

Formal Syntax & Structure

go syntaxgo
func (z *Int) SetBits(abs []Word) *Int

Parameters & Attributes

NameTypeDescription
abs[]WordUnsigned magnitude in machine words.

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() {  z := new(big.Int).SetBits([]big.Word{42})  fmt.Println(z)}
Go Reference