bigint

package
v0.0.0-...-3948e75 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2020 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Binary

func Binary(s string) (*big.Int, bool)

Binary parses a binary string into an integer, returning the integer and a boolean indicating success. Underscore may be used as a separator.

func BitsSet

func BitsSet(x *big.Int) []int

BitsSet returns the positions of set bits in x.

func BytesLittleEndian

func BytesLittleEndian(x *big.Int) []byte

BytesLittleEndian returns the absolute value of x as a little-endian byte slice.

func Clone

func Clone(x *big.Int) *big.Int

Clone returns a copy of x.

func Equal

func Equal(x, y *big.Int) bool

Equal returns whether x equals y.

func EqualInt64

func EqualInt64(x *big.Int, y int64) bool

EqualInt64 is a convenience for checking if x equals the int64 value y.

func Extract

func Extract(x *big.Int, l, h uint) *big.Int

Extract bits [l,h) and shift them to the low bits.

func FromUint64s

func FromUint64s(words []uint64) *big.Int

FromUint64s builds a big integer from little-endian 64-bit limbs.

func Hex

func Hex(s string) (*big.Int, bool)

Hex constructs an integer from a hex string, returning the integer and a boolean indicating success. Underscore may be used as a separator.

func IsNonZero

func IsNonZero(x *big.Int) bool

IsNonZero returns true if x is non-zero.

func IsPow2

func IsPow2(x *big.Int) bool

IsPow2 returns whether x is a power of 2.

func IsZero

func IsZero(x *big.Int) bool

IsZero returns true if x is zero.

func Mask

func Mask(l, h uint) *big.Int

Mask returns the integer with 1s in positions [l,h).

func Max

func Max(x, y *big.Int) *big.Int

Max returns the larger of x and y.

func Min

func Min(x, y *big.Int) *big.Int

Min returns the smaller of x and y.

func MinMax

func MinMax(x, y *big.Int) (min, max *big.Int)

MinMax returns the minimum and maximum of x and y.

func MustBinary

func MustBinary(s string) *big.Int

MustBinary constructs an integer from a binary string. It panics on error.

func MustHex

func MustHex(s string) *big.Int

MustHex constructs an integer from a hex string. It panics on error.

func One

func One() *big.Int

One returns 1.

func Ones

func Ones(n uint) *big.Int

Ones returns 2ⁿ - 1, the integer with n 1s in the low bits.

func Pow2

func Pow2(e uint) *big.Int

Pow2 returns 2ᵉ.

func Pow2UpTo

func Pow2UpTo(x *big.Int) []*big.Int

Pow2UpTo returns all powers of two ⩽ x.

func RandBits

func RandBits(r *rand.Rand, n uint) *big.Int

RandBits returns a random integer less than 2ⁿ.

func TrailingZeros

func TrailingZeros(x *big.Int) int

TrailingZeros returns the number of trailing zero bits in x. Returns 0 if x is 0.

func Uint64s

func Uint64s(x *big.Int) []uint64

Uint64s represents x in 64-bit limbs.

func Zero

func Zero() *big.Int

Zero returns 0.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL