fixed

package module
v0.0.0-...-ffd44df Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2023 License: BSD-3-Clause Imports: 8 Imported by: 0

README

fixed

Documentation

Overview

Package fixed implements fixed-size numeric types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendUvarint

func AppendUvarint[T Uint[T]](b []byte, v T) []byte

AppendUvarint appends the unsigned varint encoding of x to b and returns the resulting slice.

func MaxVarintLen

func MaxVarintLen[T Uint[T]]() int

MaxVarintLen returns the maximum number of bytes needed to represent a varint.

func Uvarint

func Uvarint[T Uint[T]](b []byte) (T, int)

Uvarint parses an unsigned varint from b and returns that value and the number of bytes read.

func VarintLen

func VarintLen[T Uint[T]](v T) int

VarintLen returns the number of bytes required to encode x.

Types

type Uint

type Uint[T any] interface {
	// Size returns the width of the integer in bits.
	Size() int
	// BitLen returns the number of bits required to represent x.
	BitLen() int
	// LeadingZeros returns the number of leading zeros in x.
	LeadingZeros() int
	// IsZero repors whether x is zero.
	IsZero() bool
	// Cmp compares x and y and returns
	//
	//   - +1 if x > y
	//   - 0 if x == y
	//   - -1 if x < y
	Cmp(T) int
	// Equal reports whether x == y.
	//
	// In general, prefer the == operator to using this method.
	Equal(T) bool
	// Add returns x+y.
	Add(T) T
	// Sub returns x-y.
	Sub(T) T
	// Mul returns x*y.
	Mul(T) T
	// QuoRem returns (q, r) such that
	//
	//	q = x/y
	//	r = x - y*q
	QuoRem(T) (q, r T)
	// And returns x&y.
	And(T) T
	// Or returns x|y.
	Or(T) T
	// Xor returns x^y.
	Xor(T) T
	// Lsh returns x<<n.
	Lsh(uint) T
	// Rsh returns x>>n.
	Rsh(uint) T
	// String returns the base-10 representation of x.
	String() string
	// contains filtered or unexported methods
}

Uint is an unsigned integer.

type Uint1024

type Uint1024 struct {
	// contains filtered or unexported fields
}

Uint1024 is an unsigned, 1024-bit integer.

It can be compared for equality with ==.

func ParseUint1024

func ParseUint1024(s string, base int) (Uint1024, error)

ParseUint1024 returns the value of s in the given base.

func U1024

func U1024(u0, u1, u2, u3, u4, u5, u6, u7, u8, u9, u10, u11, u12, u13, u14, u15 uint64) Uint1024

U1024 constructs a Uint1024.

The inputs are in ascending (low to high) order. For example, a uint64 x can be converted to a Uint1024, with

U1024(x, 0, 0, ...)

or more simply

U1024From64(x)

func U1024From64

func U1024From64(x uint64) Uint1024

U1024From64 constructs a Uint1024 from a uint64.

func (Uint1024) Add

func (x Uint1024) Add(y Uint1024) Uint1024

Add returns x+y.

func (Uint1024) AddCheck

func (x Uint1024) AddCheck(y Uint1024) (z Uint1024, carry uint64)

AddCheck returns x+y.

carry is 1 if x+y overflows and 0 otherwise.

func (Uint1024) And

func (x Uint1024) And(y Uint1024) Uint1024

And returns x&y.

func (Uint1024) BitLen

func (x Uint1024) BitLen() int

BitLen returns the number of bits required to represent x.

func (Uint1024) Bytes

func (x Uint1024) Bytes(b *[128]byte)

Bytes encodes x as a little-endian integer.

func (Uint1024) Cmp

func (x Uint1024) Cmp(y Uint1024) int

Cmp compares x and y and returns

  • +1 if x > y
  • 0 if x == y
  • -1 if x < y

func (Uint1024) Equal

func (x Uint1024) Equal(y Uint1024) bool

Equal reports whether x == y.

In general, prefer the == operator to using this method.

func (Uint1024) Exp

func (x Uint1024) Exp(y, m Uint1024) Uint1024

Exp return x^y mod m.

If m == 0, Exp simply returns x^y.

func (Uint1024) GoString

func (x Uint1024) GoString() string

func (Uint1024) IsZero

func (x Uint1024) IsZero() bool

IsZero is shorthand for x == Uint1024{}.

func (Uint1024) LeadingZeros

func (x Uint1024) LeadingZeros() int

LeadingZeros returns the number of leading zeros in x.

func (Uint1024) Lsh

func (x Uint1024) Lsh(n uint) Uint1024

Lsh returns x<<n.

func (Uint1024) Mul

func (x Uint1024) Mul(y Uint1024) Uint1024

Mul returns x*y.

func (Uint1024) MulCheck

func (x Uint1024) MulCheck(y Uint1024) (Uint1024, bool)

MulCheck returns x*y and reports whether the multiplication oveflowed.

func (Uint1024) Or

func (x Uint1024) Or(y Uint1024) Uint1024

Or returns x|y.

func (Uint1024) QuoRem

func (x Uint1024) QuoRem(y Uint1024) (q, r Uint1024)

QuoRem returns (q, r) such that

q = x/y
r = x - y*q

func (Uint1024) Rsh

func (x Uint1024) Rsh(n uint) Uint1024

Rsh returns x>>n.

func (*Uint1024) SetBytes

func (x *Uint1024) SetBytes(b []byte) error

SetBytes sets x to the encoded little-endian integer b.

func (Uint1024) Size

func (Uint1024) Size() int

Size returns the width of the integer in bits.

func (Uint1024) String

func (x Uint1024) String() string

String returns the base-10 representation of x.

func (Uint1024) Sub

func (x Uint1024) Sub(y Uint1024) Uint1024

Sub returns x-y.

func (Uint1024) SubCheck

func (x Uint1024) SubCheck(y Uint1024) (z Uint1024, borrow uint64)

SubCheck returns x-y.

borrow is 1 if x-y overflows and 0 otherwise.

func (Uint1024) Xor

func (x Uint1024) Xor(y Uint1024) Uint1024

Xor returns x^y.

type Uint128

type Uint128 struct {
	// contains filtered or unexported fields
}

Uint128 is an unsigned, 128-bit integer.

It can be compared for equality with ==.

func ParseUint128

func ParseUint128(s string, base int) (Uint128, error)

ParseUint128 returns the value of s in the given base.

func U128

func U128(u0, u1 uint64) Uint128

U128 constructs a Uint128.

The inputs are in ascending (low to high) order. For example, a uint64 x can be converted to a Uint128, with

U128(x, 0, 0, ...)

or more simply

U128From64(x)

func U128From64

func U128From64(x uint64) Uint128

U128From64 constructs a Uint128 from a uint64.

func (Uint128) Add

func (x Uint128) Add(y Uint128) Uint128

Add returns x+y.

func (Uint128) AddCheck

func (x Uint128) AddCheck(y Uint128) (z Uint128, carry uint64)

AddCheck returns x+y.

carry is 1 if x+y overflows and 0 otherwise.

func (Uint128) And

func (x Uint128) And(y Uint128) Uint128

And returns x&y.

func (Uint128) BitLen

func (x Uint128) BitLen() int

BitLen returns the number of bits required to represent x.

func (Uint128) Bytes

func (x Uint128) Bytes(b *[16]byte)

Bytes encodes x as a little-endian integer.

func (Uint128) Cmp

func (x Uint128) Cmp(y Uint128) int

Cmp compares x and y and returns

  • +1 if x > y
  • 0 if x == y
  • -1 if x < y

func (Uint128) Equal

func (x Uint128) Equal(y Uint128) bool

Equal reports whether x == y.

In general, prefer the == operator to using this method.

func (Uint128) GoString

func (x Uint128) GoString() string

func (Uint128) IsZero

func (x Uint128) IsZero() bool

IsZero is shorthand for x == Uint128{}.

func (Uint128) LeadingZeros

func (x Uint128) LeadingZeros() int

LeadingZeros returns the number of leading zeros in x.

func (Uint128) Lsh

func (x Uint128) Lsh(n uint) Uint128

Lsh returns x<<n.

func (Uint128) Mul

func (x Uint128) Mul(y Uint128) Uint128

Mul returns x*y.

func (Uint128) MulCheck

func (x Uint128) MulCheck(y Uint128) (Uint128, bool)

MulCheck returns x*y and reports whether the multiplication oveflowed.

func (Uint128) Or

func (x Uint128) Or(y Uint128) Uint128

Or returns x|y.

func (Uint128) QuoRem

func (x Uint128) QuoRem(y Uint128) (q, r Uint128)

QuoRem returns (q, r) such that

q = x/y
r = x - y*q

func (Uint128) Rsh

func (x Uint128) Rsh(n uint) Uint128

Rsh returns x>>n.

func (*Uint128) SetBytes

func (x *Uint128) SetBytes(b []byte) error

SetBytes sets x to the encoded little-endian integer b.

func (Uint128) Size

func (Uint128) Size() int

Size returns the width of the integer in bits.

func (Uint128) String

func (x Uint128) String() string

String returns the base-10 representation of x.

func (Uint128) Sub

func (x Uint128) Sub(y Uint128) Uint128

Sub returns x-y.

func (Uint128) SubCheck

func (x Uint128) SubCheck(y Uint128) (z Uint128, borrow uint64)

SubCheck returns x-y.

borrow is 1 if x-y overflows and 0 otherwise.

func (Uint128) Xor

func (x Uint128) Xor(y Uint128) Uint128

Xor returns x^y.

type Uint192

type Uint192 struct {
	// contains filtered or unexported fields
}

Uint192 is an unsigned, 192-bit integer.

It can be compared for equality with ==.

func ParseUint192

func ParseUint192(s string, base int) (Uint192, error)

ParseUint192 returns the value of s in the given base.

func U192

func U192(u0, u1, u2 uint64) Uint192

U192 constructs a Uint192.

The inputs are in ascending (low to high) order. For example, a uint64 x can be converted to a Uint192, with

U192(x, 0, 0, ...)

or more simply

U192From64(x)

func U192From64

func U192From64(x uint64) Uint192

U192From64 constructs a Uint192 from a uint64.

func (Uint192) Add

func (x Uint192) Add(y Uint192) Uint192

Add returns x+y.

func (Uint192) AddCheck

func (x Uint192) AddCheck(y Uint192) (z Uint192, carry uint64)

AddCheck returns x+y.

carry is 1 if x+y overflows and 0 otherwise.

func (Uint192) And

func (x Uint192) And(y Uint192) Uint192

And returns x&y.

func (Uint192) BitLen

func (x Uint192) BitLen() int

BitLen returns the number of bits required to represent x.

func (Uint192) Cmp

func (x Uint192) Cmp(y Uint192) int

Cmp compares x and y and returns

  • +1 if x > y
  • 0 if x == y
  • -1 if x < y

func (Uint192) Equal

func (x Uint192) Equal(y Uint192) bool

Equal reports whether x == y.

In general, prefer the == operator to using this method.

func (Uint192) GoString

func (x Uint192) GoString() string

func (Uint192) IsZero

func (x Uint192) IsZero() bool

IsZero is shorthand for x == Uint192{}.

func (Uint192) LeadingZeros

func (x Uint192) LeadingZeros() int

LeadingZeros returns the number of leading zeros in x.

func (Uint192) Lsh

func (x Uint192) Lsh(n uint) Uint192

Lsh returns x<<n.

func (Uint192) Mul

func (x Uint192) Mul(y Uint192) Uint192

Mul returns x*y.

func (Uint192) MulCheck

func (x Uint192) MulCheck(y Uint192) (Uint192, bool)

MulCheck returns x*y and indicates whether the multiplication overflowed.

func (Uint192) Or

func (x Uint192) Or(y Uint192) Uint192

Or returns x|y.

func (Uint192) QuoRem

func (x Uint192) QuoRem(y Uint192) (q, r Uint192)

QuoRem returns (q, r) such that

q = x/y
r = x - y*q

func (Uint192) Rsh

func (x Uint192) Rsh(n uint) Uint192

Rsh returns x>>n.

func (Uint192) Size

func (Uint192) Size() int

Size returns the width of the integer in bits.

func (Uint192) String

func (x Uint192) String() string

String returns the base-10 representation of x.

func (Uint192) Sub

func (x Uint192) Sub(y Uint192) Uint192

Sub returns x-y.

func (Uint192) SubCheck

func (x Uint192) SubCheck(y Uint192) (z Uint192, borrow uint64)

SubCheck returns x-y.

borrow is 1 if x+y overflows and 0 otherwise.

func (Uint192) Xor

func (x Uint192) Xor(y Uint192) Uint192

Xor returns x^y.

type Uint2048

type Uint2048 struct {
	// contains filtered or unexported fields
}

Uint2048 is an unsigned, 2048-bit integer.

It can be compared for equality with ==.

func ParseUint2048

func ParseUint2048(s string, base int) (Uint2048, error)

ParseUint2048 returns the value of s in the given base.

func U2048

func U2048(u0, u1, u2, u3, u4, u5, u6, u7, u8, u9, u10, u11, u12, u13, u14, u15, u16, u17, u18, u19, u20, u21, u22, u23, u24, u25, u26, u27, u28, u29, u30, u31 uint64) Uint2048

U2048 constructs a Uint2048.

The inputs are in ascending (low to high) order. For example, a uint64 x can be converted to a Uint2048, with

U2048(x, 0, 0, ...)

or more simply

U2048From64(x)

func U2048From64

func U2048From64(x uint64) Uint2048

U2048From64 constructs a Uint2048 from a uint64.

func (Uint2048) Add

func (x Uint2048) Add(y Uint2048) Uint2048

Add returns x+y.

func (Uint2048) AddCheck

func (x Uint2048) AddCheck(y Uint2048) (z Uint2048, carry uint64)

AddCheck returns x+y.

carry is 1 if x+y overflows and 0 otherwise.

func (Uint2048) And

func (x Uint2048) And(y Uint2048) Uint2048

And returns x&y.

func (Uint2048) BitLen

func (x Uint2048) BitLen() int

BitLen returns the number of bits required to represent x.

func (Uint2048) Bytes

func (x Uint2048) Bytes(b *[256]byte)

Bytes encodes x as a little-endian integer.

func (Uint2048) Cmp

func (x Uint2048) Cmp(y Uint2048) int

Cmp compares x and y and returns

  • +1 if x > y
  • 0 if x == y
  • -1 if x < y

func (Uint2048) Equal

func (x Uint2048) Equal(y Uint2048) bool

Equal reports whether x == y.

In general, prefer the == operator to using this method.

func (Uint2048) Exp

func (x Uint2048) Exp(y, m Uint2048) Uint2048

Exp return x^y mod m.

If m == 0, Exp simply returns x^y.

func (Uint2048) GoString

func (x Uint2048) GoString() string

func (Uint2048) IsZero

func (x Uint2048) IsZero() bool

IsZero is shorthand for x == Uint2048{}.

func (Uint2048) LeadingZeros

func (x Uint2048) LeadingZeros() int

LeadingZeros returns the number of leading zeros in x.

func (Uint2048) Lsh

func (x Uint2048) Lsh(n uint) Uint2048

Lsh returns x<<n.

func (Uint2048) Mul

func (x Uint2048) Mul(y Uint2048) Uint2048

Mul returns x*y.

func (Uint2048) MulCheck

func (x Uint2048) MulCheck(y Uint2048) (Uint2048, bool)

MulCheck returns x*y and reports whether the multiplication oveflowed.

func (Uint2048) Or

func (x Uint2048) Or(y Uint2048) Uint2048

Or returns x|y.

func (Uint2048) QuoRem

func (x Uint2048) QuoRem(y Uint2048) (q, r Uint2048)

QuoRem returns (q, r) such that

q = x/y
r = x - y*q

func (Uint2048) Rsh

func (x Uint2048) Rsh(n uint) Uint2048

Rsh returns x>>n.

func (*Uint2048) SetBytes

func (x *Uint2048) SetBytes(b []byte) error

SetBytes sets x to the encoded little-endian integer b.

func (Uint2048) Size

func (Uint2048) Size() int

Size returns the width of the integer in bits.

func (Uint2048) String

func (x Uint2048) String() string

String returns the base-10 representation of x.

func (Uint2048) Sub

func (x Uint2048) Sub(y Uint2048) Uint2048

Sub returns x-y.

func (Uint2048) SubCheck

func (x Uint2048) SubCheck(y Uint2048) (z Uint2048, borrow uint64)

SubCheck returns x-y.

borrow is 1 if x-y overflows and 0 otherwise.

func (Uint2048) Xor

func (x Uint2048) Xor(y Uint2048) Uint2048

Xor returns x^y.

type Uint256

type Uint256 struct {
	// contains filtered or unexported fields
}

Uint256 is an unsigned, 256-bit integer.

It can be compared for equality with ==.

func ParseUint256

func ParseUint256(s string, base int) (Uint256, error)

ParseUint256 returns the value of s in the given base.

func U256

func U256(u0, u1, u2, u3 uint64) Uint256

U256 constructs a Uint256.

The inputs are in ascending (low to high) order. For example, a uint64 x can be converted to a Uint256, with

U256(x, 0, 0, ...)

or more simply

U256From64(x)

func U256From64

func U256From64(x uint64) Uint256

U256From64 constructs a Uint256 from a uint64.

func (Uint256) Add

func (x Uint256) Add(y Uint256) Uint256

Add returns x+y.

func (Uint256) AddCheck

func (x Uint256) AddCheck(y Uint256) (z Uint256, carry uint64)

AddCheck returns x+y.

carry is 1 if x+y overflows and 0 otherwise.

func (Uint256) And

func (x Uint256) And(y Uint256) Uint256

And returns x&y.

func (Uint256) BitLen

func (x Uint256) BitLen() int

BitLen returns the number of bits required to represent x.

func (Uint256) Bytes

func (x Uint256) Bytes(b *[32]byte)

Bytes encodes x as a little-endian integer.

func (Uint256) Cmp

func (x Uint256) Cmp(y Uint256) int

Cmp compares x and y and returns

  • +1 if x > y
  • 0 if x == y
  • -1 if x < y

func (Uint256) Equal

func (x Uint256) Equal(y Uint256) bool

Equal reports whether x == y.

In general, prefer the == operator to using this method.

func (Uint256) Exp

func (x Uint256) Exp(y, m Uint256) Uint256

Exp return x^y mod m.

If m == 0, Exp simply returns x^y.

func (Uint256) GoString

func (x Uint256) GoString() string

func (Uint256) IsZero

func (x Uint256) IsZero() bool

IsZero is shorthand for x == Uint256{}.

func (Uint256) LeadingZeros

func (x Uint256) LeadingZeros() int

LeadingZeros returns the number of leading zeros in x.

func (Uint256) Lsh

func (x Uint256) Lsh(n uint) Uint256

Lsh returns x<<n.

func (Uint256) Mul

func (x Uint256) Mul(y Uint256) Uint256

Mul returns x*y.

func (Uint256) MulCheck

func (x Uint256) MulCheck(y Uint256) (Uint256, bool)

MulCheck returns x*y and reports whether the multiplication oveflowed.

func (Uint256) Or

func (x Uint256) Or(y Uint256) Uint256

Or returns x|y.

func (Uint256) QuoRem

func (x Uint256) QuoRem(y Uint256) (q, r Uint256)

QuoRem returns (q, r) such that

q = x/y
r = x - y*q

func (Uint256) Rsh

func (x Uint256) Rsh(n uint) Uint256

Rsh returns x>>n.

func (*Uint256) SetBytes

func (x *Uint256) SetBytes(b []byte) error

SetBytes sets x to the encoded little-endian integer b.

func (Uint256) Size

func (Uint256) Size() int

Size returns the width of the integer in bits.

func (Uint256) String

func (x Uint256) String() string

String returns the base-10 representation of x.

func (Uint256) Sub

func (x Uint256) Sub(y Uint256) Uint256

Sub returns x-y.

func (Uint256) SubCheck

func (x Uint256) SubCheck(y Uint256) (z Uint256, borrow uint64)

SubCheck returns x-y.

borrow is 1 if x-y overflows and 0 otherwise.

func (Uint256) Xor

func (x Uint256) Xor(y Uint256) Uint256

Xor returns x^y.

type Uint512

type Uint512 struct {
	// contains filtered or unexported fields
}

Uint512 is an unsigned, 512-bit integer.

It can be compared for equality with ==.

func ParseUint512

func ParseUint512(s string, base int) (Uint512, error)

ParseUint512 returns the value of s in the given base.

func U512

func U512(u0, u1, u2, u3, u4, u5, u6, u7 uint64) Uint512

U512 constructs a Uint512.

The inputs are in ascending (low to high) order. For example, a uint64 x can be converted to a Uint512, with

U512(x, 0, 0, ...)

or more simply

U512From64(x)

func U512From64

func U512From64(x uint64) Uint512

U512From64 constructs a Uint512 from a uint64.

func (Uint512) Add

func (x Uint512) Add(y Uint512) Uint512

Add returns x+y.

func (Uint512) AddCheck

func (x Uint512) AddCheck(y Uint512) (z Uint512, carry uint64)

AddCheck returns x+y.

carry is 1 if x+y overflows and 0 otherwise.

func (Uint512) And

func (x Uint512) And(y Uint512) Uint512

And returns x&y.

func (Uint512) BitLen

func (x Uint512) BitLen() int

BitLen returns the number of bits required to represent x.

func (Uint512) Bytes

func (x Uint512) Bytes(b *[64]byte)

Bytes encodes x as a little-endian integer.

func (Uint512) Cmp

func (x Uint512) Cmp(y Uint512) int

Cmp compares x and y and returns

  • +1 if x > y
  • 0 if x == y
  • -1 if x < y

func (Uint512) Equal

func (x Uint512) Equal(y Uint512) bool

Equal reports whether x == y.

In general, prefer the == operator to using this method.

func (Uint512) Exp

func (x Uint512) Exp(y, m Uint512) Uint512

Exp return x^y mod m.

If m == 0, Exp simply returns x^y.

func (Uint512) GoString

func (x Uint512) GoString() string

func (Uint512) IsZero

func (x Uint512) IsZero() bool

IsZero is shorthand for x == Uint512{}.

func (Uint512) LeadingZeros

func (x Uint512) LeadingZeros() int

LeadingZeros returns the number of leading zeros in x.

func (Uint512) Lsh

func (x Uint512) Lsh(n uint) Uint512

Lsh returns x<<n.

func (Uint512) Mul

func (x Uint512) Mul(y Uint512) Uint512

Mul returns x*y.

func (Uint512) MulCheck

func (x Uint512) MulCheck(y Uint512) (Uint512, bool)

MulCheck returns x*y and reports whether the multiplication oveflowed.

func (Uint512) Or

func (x Uint512) Or(y Uint512) Uint512

Or returns x|y.

func (Uint512) QuoRem

func (x Uint512) QuoRem(y Uint512) (q, r Uint512)

QuoRem returns (q, r) such that

q = x/y
r = x - y*q

func (Uint512) Rsh

func (x Uint512) Rsh(n uint) Uint512

Rsh returns x>>n.

func (*Uint512) SetBytes

func (x *Uint512) SetBytes(b []byte) error

SetBytes sets x to the encoded little-endian integer b.

func (Uint512) Size

func (Uint512) Size() int

Size returns the width of the integer in bits.

func (Uint512) String

func (x Uint512) String() string

String returns the base-10 representation of x.

func (Uint512) Sub

func (x Uint512) Sub(y Uint512) Uint512

Sub returns x-y.

func (Uint512) SubCheck

func (x Uint512) SubCheck(y Uint512) (z Uint512, borrow uint64)

SubCheck returns x-y.

borrow is 1 if x-y overflows and 0 otherwise.

func (Uint512) Xor

func (x Uint512) Xor(y Uint512) Uint512

Xor returns x^y.

type Uint96

type Uint96 struct {
	// contains filtered or unexported fields
}

Uint96 is an unsigned, 96-bit integer.

It can be compared for equality with ==.

func ParseUint96

func ParseUint96(s string, base int) (Uint96, error)

ParseUint96 returns the value of s in the given base.

func U96

func U96(u0 uint64, u1 uint32) Uint96

U96 constructs a Uint96.

The inputs are in ascending (low to high) order. For example, a uint64 x can be converted to a Uint96, with

U96(x, 0, 0, ...)

or more simply

U96From64(x)

func U96From64

func U96From64(x uint64) Uint96

U96From64 constructs a Uint96 from a uint64.

func (Uint96) Add

func (x Uint96) Add(y Uint96) Uint96

Add returns x+y.

carry is 1 if x+y overflows and 0 otherwise.

func (Uint96) AddCheck

func (x Uint96) AddCheck(y Uint96) (z Uint96, carry uint32)

AddCheck returns x+y.

carry is 1 if x+y overflows and 0 otherwise.

func (Uint96) And

func (x Uint96) And(y Uint96) Uint96

And returns x&y.

func (Uint96) BitLen

func (x Uint96) BitLen() int

BitLen returns the number of bits required to represent x.

func (Uint96) Bytes

func (x Uint96) Bytes(b *[12]byte)

Bytes encodes x as a little-endian integer.

func (Uint96) Cmp

func (x Uint96) Cmp(y Uint96) int

Cmp compares x and y and returns

  • +1 if x > y
  • 0 if x == y
  • -1 if x < y

func (Uint96) Equal

func (x Uint96) Equal(y Uint96) bool

Equal reports whether x == y.

In general, prefer the == operator to using this method.

func (Uint96) GoString

func (x Uint96) GoString() string

func (Uint96) IsZero

func (x Uint96) IsZero() bool

IsZero is shorthand for x == Uint96{}.

func (Uint96) LeadingZeros

func (x Uint96) LeadingZeros() int

LeadingZeros returns the number of leading zeros in x.

func (Uint96) Lsh

func (x Uint96) Lsh(n uint) Uint96

Lsh returns x<<n.

func (Uint96) Mul

func (x Uint96) Mul(y Uint96) Uint96

Mul returns x*y.

func (Uint96) MulCheck

func (x Uint96) MulCheck(y Uint96) (Uint96, bool)

MulCheck returns x*y and indicates whether the multiplication overflowed.

func (Uint96) Or

func (x Uint96) Or(y Uint96) Uint96

Or returns x|y.

func (Uint96) QuoRem

func (x Uint96) QuoRem(y Uint96) (q, r Uint96)

QuoRem returns (q, r) such that

q = x/y
r = x - y*q

func (Uint96) Rsh

func (x Uint96) Rsh(n uint) Uint96

Rsh returns x>>n.

func (*Uint96) SetBytes

func (x *Uint96) SetBytes(b []byte) error

SetBytes sets x to the encoded little-endian integer b.

func (Uint96) Size

func (Uint96) Size() int

Size returns the width of the integer in bits.

func (Uint96) String

func (x Uint96) String() string

String returns the base-10 representation of x.

func (Uint96) Sub

func (x Uint96) Sub(y Uint96) Uint96

Sub returns x-y.

func (Uint96) SubCheck

func (x Uint96) SubCheck(y Uint96) (z Uint96, borrow uint32)

SubCheck returns x-y.

borrow is 1 if x+y overflows and 0 otherwise.

func (Uint96) Xor

func (x Uint96) Xor(y Uint96) Uint96

Xor returns x^y.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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