uint128

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Uint128

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

A Uint128 is an unsigned 128-bit number.

var Zero Uint128

Zero is a zero-valued uint128.

func From64

func From64(v uint64) Uint128

From64 converts v to a Uint128 value.

func FromBig

func FromBig(i *big.Int) (u Uint128)

FromBig converts i to a Uint128 value. It panics if i is negative or overflows 128 bits.

func FromBytes

func FromBytes(b []byte) Uint128

FromBytes converts b to a Uint128 value.

func New

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) Add64

func (u Uint128) Add64(v uint64) Uint128

Add64 returns u+v.

func (Uint128) And

func (u Uint128) And(v Uint128) Uint128

And returns u&v.

func (Uint128) And64

func (u Uint128) And64(v uint64) Uint128

And64 returns u&v.

func (Uint128) Big

func (u Uint128) Big() *big.Int

Big returns u as a *big.Int.

func (Uint128) Cmp

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

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) Div

func (u Uint128) Div(v Uint128) Uint128

Div returns u/v.

func (Uint128) Div64

func (u Uint128) Div64(v uint64) Uint128

Div64 returns u/v.

func (Uint128) Equals

func (u Uint128) Equals(v Uint128) bool

Equals returns true if u == v.

Uint128 values can be compared directly with ==, but use of the Equals method is preferred for consistency.

func (Uint128) Equals64

func (u Uint128) Equals64(v uint64) bool

Equals64 returns true if u == v.

func (Uint128) IsZero

func (u Uint128) IsZero() bool

IsZero returns true if u == 0.

func (Uint128) Lsh

func (u Uint128) Lsh(n uint) (s Uint128)

Lsh returns u<<n.

func (Uint128) Mul

func (u Uint128) Mul(v Uint128) Uint128

Mul returns u*v.

func (Uint128) Mul64

func (u Uint128) Mul64(v uint64) Uint128

Mul64 returns u*v.

func (Uint128) Or

func (u Uint128) Or(v Uint128) Uint128

Or returns u|v.

func (Uint128) Or64

func (u Uint128) Or64(v uint64) Uint128

Or64 returns u|v.

func (Uint128) PutBytes

func (u Uint128) PutBytes(b []byte)

PutBytes stores u in b in little-endian order. It panics if len(b) < 16.

func (Uint128) QuoRem

func (u Uint128) QuoRem(v Uint128) (q, r Uint128)

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

func (Uint128) QuoRem64

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

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

func (Uint128) Rsh

func (u Uint128) Rsh(n uint) (s Uint128)

Rsh returns u>>n.

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

Sub returns u-v.

func (Uint128) Sub64

func (u Uint128) Sub64(v uint64) Uint128

Sub64 returns u-v.

func (Uint128) Xor

func (u Uint128) Xor(v Uint128) Uint128

Xor returns u^v.

func (Uint128) Xor64

func (u Uint128) Xor64(v uint64) Uint128

Xor64 returns u^v.

Jump to

Keyboard shortcuts

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