uint128

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Uint128

type Uint128 struct {
	Hi, Lo uint64
}

Uint128 is a big-endian 128 bit unsigned integer which wraps two uint64s.

var Zero Uint128

func From64 added in v0.0.20

func From64(v uint64) Uint128

From64 converts v to a Uint128 value.

func FromBytes

func FromBytes(b []byte) Uint128

FromBytes parses the byte slice as a 128 bit big-endian unsigned integer. The caller is responsible for ensuring the byte slice contains 16 bytes.

func FromInts

func FromInts(hi uint64, lo uint64) Uint128

FromInts takes in two unsigned 64-bit integers and constructs a Uint128.

func FromString

func FromString(s string) (Uint128, error)

FromString parses a hexadecimal string as a 128-bit big-endian unsigned integer.

func New added in v0.0.20

func New(lo, hi uint64) Uint128

New returns the Uint128 value (lo,hi).

func (Uint128) Add

func (u Uint128) Add(v Uint128) Uint128

Add returns u+v.

func (Uint128) And

func (u Uint128) And(o Uint128) Uint128

And returns a new Uint128 that is the bitwise AND of two Uint128 values.

func (Uint128) Cmp added in v0.0.20

func (u Uint128) Cmp(v Uint128) int

Cmp compares u and v and returns:

-1 if u <  v
 0 if u == v
+1 if u >  v

func (Uint128) Cmp64 added in v0.0.20

func (u Uint128) Cmp64(v uint64) int

Cmp64 compares u and v and returns:

-1 if u <  v
 0 if u == v
+1 if u >  v

func (Uint128) Compare

func (u Uint128) Compare(o Uint128) int

Compare compares the two Uint128.

func (Uint128) Equal

func (u Uint128) Equal(o Uint128) bool

Equal returns whether or not the Uint128 are equivalent.

func (Uint128) Equals64 added in v0.0.20

func (u Uint128) Equals64(v uint64) bool

Equals64 returns true if u == v.

func (Uint128) GetBytes

func (u Uint128) GetBytes() []byte

GetBytes returns a big-endian byte representation.

func (Uint128) HexString

func (u Uint128) HexString() string

String returns a hexadecimal string representation.

func (Uint128) IsZero

func (u Uint128) IsZero() bool

IsZero returns true if u == 0.

func (Uint128) Or

func (u Uint128) Or(o Uint128) Uint128

Or returns a new Uint128 that is the bitwise OR of two Uint128 values.

func (Uint128) QuoRem64

func (u Uint128) QuoRem64(v uint64) (q Uint128, r uint64)

QuoRem64 returns q = u/v and r = u%v.

func (Uint128) String

func (u Uint128) String() string

String returns the base-10 representation of u as a string.

func (Uint128) Sub

func (u Uint128) Sub(v Uint128) Uint128

func (Uint128) Xor

func (u Uint128) Xor(o Uint128) Uint128

Xor returns a new Uint128 that is the bitwise XOR of two Uint128 values.

Jump to

Keyboard shortcuts

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