int128

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 7 Imported by: 0

README

go-int128

GoDoc Go Report Card

128-bit integer arithmetics in Go

Install

go get github.com/agmt/go-int128

Benchmark

goos: linux
goarch: arm64
pkg: github.com/agmt/go-int128

BenchmarkAdd/int64+int64-6                                                    	1000000000	         0.3134 ns/op	       0 B/op	       0 allocs/op
BenchmarkBigAdd/big.int+big.int-6                                             	182255571	         6.578 ns/op	       0 B/op	       0 allocs/op
BenchmarkUint128Add/uint128+uint128-6                                         	1000000000	         0.3510 ns/op	       0 B/op	       0 allocs/op
BenchmarkInt128Add/int128+iint128-6                                           	1000000000	         0.3514 ns/op	       0 B/op	       0 allocs/op

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnmarshalError = errors.New("wrong i128 value")
)
View Source
var (
	ZeroInt128 = Int128{
		// contains filtered or unexported fields
	}
)
View Source
var (
	ZeroUint128 = Uint128{
		// contains filtered or unexported fields
	}
)

Functions

func CmpInt128

func CmpInt128(lhs, rhs Int128) int

func CmpUint128

func CmpUint128(lhs, rhs Uint128) int

func LessInt128 added in v1.0.0

func LessInt128(lhs Int128, rhs Int128) bool

func LessUint128 added in v1.0.0

func LessUint128(lhs Uint128, rhs Uint128) bool

Types

type Int128

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

func AddCI128

func AddCI128(lhs Int128, rhs Int128, carry uint64) (sum Int128, carryOut uint64)

func AddI128

func AddI128(lhs Int128, rhs Int128) (sum Int128)

func MustInt128FromString added in v1.0.0

func MustInt128FromString(s string) Int128

func NewInt128FromString added in v1.0.0

func NewInt128FromString(s string, base int) (r Int128, ok bool)

func SubCI128

func SubCI128(lhs Int128, rhs Int128, borrow uint64) (diff Int128, borrowOut uint64)

func SubI128

func SubI128(lhs Int128, rhs Int128) (diff Int128)

func (Int128) Add

func (lhs Int128) Add(rhs Int128) Int128

func (*Int128) AddAssign

func (lhs *Int128) AddAssign(rhs Int128) *Int128

func (Int128) BigInt

func (lhs Int128) BigInt() *big.Int

func (Int128) Equal

func (lhs Int128) Equal(rhs Int128) bool

func (*Int128) FromBigEndian

func (lhs *Int128) FromBigEndian(buf []byte)

func (*Int128) FromLittleEndian

func (lhs *Int128) FromLittleEndian(buf []byte)

func (Int128) IsNeg

func (lhs Int128) IsNeg() bool

func (Int128) IsZero

func (lhs Int128) IsZero() bool

func (Int128) Less

func (lhs Int128) Less(rhs Int128) bool

func (Int128) MarshalJSON

func (lhs Int128) MarshalJSON() ([]byte, error)

func (Int128) Neg

func (lhs Int128) Neg() (neg Int128)

func (Int128) PutBigEndian

func (lhs Int128) PutBigEndian(buf []byte)

func (Int128) PutLittleEndian

func (lhs Int128) PutLittleEndian(buf []byte)

func (Int128) String

func (lhs Int128) String() string

func (Int128) Sub

func (lhs Int128) Sub(rhs Int128) Int128

func (*Int128) SubAssign

func (lhs *Int128) SubAssign(rhs Int128) *Int128

func (*Int128) UnmarshalJSON

func (lhs *Int128) UnmarshalJSON(p []byte) (err error)

type Uint128

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

func AddCU128

func AddCU128(lhs Uint128, rhs Uint128, carry uint64) (sum Uint128, carryOut uint64)

func AddU128

func AddU128(lhs Uint128, rhs Uint128) (sum Uint128)

func MustUint128FromString added in v1.0.0

func MustUint128FromString(s string) Uint128

func NewUint128FromString added in v1.0.0

func NewUint128FromString(s string, base int) (r Uint128, ok bool)

func SubCU128

func SubCU128(lhs Uint128, rhs Uint128, borrow uint64) (diff Uint128, borrowOut uint64)

func SubU128

func SubU128(lhs Uint128, rhs Uint128) (diff Uint128)

func (Uint128) Add

func (lhs Uint128) Add(rhs Uint128) Uint128

func (*Uint128) AddAssign

func (lhs *Uint128) AddAssign(rhs Uint128) *Uint128

func (Uint128) BigInt

func (lhs Uint128) BigInt() *big.Int

func (Uint128) Equal

func (lhs Uint128) Equal(rhs Uint128) bool

func (*Uint128) FromBigEndian

func (lhs *Uint128) FromBigEndian(buf []byte)

func (*Uint128) FromLittleEndian

func (lhs *Uint128) FromLittleEndian(buf []byte)

func (Uint128) IsNeg

func (lhs Uint128) IsNeg() bool

func (Uint128) IsZero

func (lhs Uint128) IsZero() bool

func (Uint128) Less

func (lhs Uint128) Less(rhs Uint128) bool

func (Uint128) MarshalJSON

func (lhs Uint128) MarshalJSON() ([]byte, error)

func (Uint128) Neg

func (lhs Uint128) Neg() (neg Uint128)

func (Uint128) PutBigEndian

func (lhs Uint128) PutBigEndian(buf []byte)

func (Uint128) PutLittleEndian

func (lhs Uint128) PutLittleEndian(buf []byte)

func (Uint128) String

func (lhs Uint128) String() string

func (Uint128) Sub

func (lhs Uint128) Sub(rhs Uint128) Uint128

func (*Uint128) SubAssign

func (lhs *Uint128) SubAssign(rhs Uint128) *Uint128

func (*Uint128) UnmarshalJSON

func (lhs *Uint128) UnmarshalJSON(p []byte) (err error)

Jump to

Keyboard shortcuts

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