number

package
v2.1.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2019 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Zero       = Uint(0)
	One        = Uint(1)
	Two        = Uint(2)
	MaxUint256 = Uint(0).SetBytes(common.Hex2Bytes("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"))

	MinOne = Int(-1)

	// "typedefs"
	Uint = Uint256
	Int  = Int256
)

Functions

This section is empty.

Types

type Initialiser

type Initialiser func(n int64) *Number

Number function

func NewInitialiser

func NewInitialiser(limiter func(*Number) *Number) Initialiser

Returns a new initialiser for a new *Number without having to expose certain fields

type Number

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

A Number represents a generic integer with a bounding function limiter. Limit is called after each operations to give "fake" bounded integers. New types of Number can be created through NewInitialiser returning a lambda with the new Initialiser.

func Big

func Big(n int64) *Number

Returns a Number with a SIGNED unlimited size

func Int256

func Int256(n int64) *Number

Return a Number with a SIGNED limiter up to 256 bits

func Uint256

func Uint256(n int64) *Number

Return a Number with a UNSIGNED limiter up to 256 bits

func (*Number) Add

func (i *Number) Add(x, y *Number) *Number

Sets i to sum of x+y

func (*Number) Bytes

func (i *Number) Bytes() []byte

Returns the byte representation of i

func (*Number) Cmp

func (i *Number) Cmp(x *Number) int

Cmp compares x and y and returns:

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

func (*Number) Div

func (i *Number) Div(x, y *Number) *Number

Sets i to the quotient prodject of x/y

func (*Number) FirstBitSet

func (i *Number) FirstBitSet() int

Returns the index of the first bit that's set to 1

func (*Number) Int256

func (i *Number) Int256() *Number

Returns the signed version of i

func (*Number) Int64

func (i *Number) Int64() int64

Int64 returns the int64 representation of x. If x cannot be represented in an int64, the result is undefined.

func (*Number) Lsh

func (i *Number) Lsh(x *Number, s uint) *Number

Sets i to x << s

func (*Number) Mod

func (i *Number) Mod(x, y *Number) *Number

Sets i to x % y

func (*Number) Mul

func (i *Number) Mul(x, y *Number) *Number

Sets i to product of x*y

func (*Number) Pow

func (i *Number) Pow(x, y *Number) *Number

Sets i to x^y

func (*Number) Set

func (i *Number) Set(x *Number) *Number

Set x to i

func (*Number) SetBytes

func (i *Number) SetBytes(x []byte) *Number

Set x bytes to i

func (*Number) String

func (i *Number) String() string

Returns the string representation of i

func (*Number) Sub

func (i *Number) Sub(x, y *Number) *Number

Sets i to difference of x-y

func (*Number) Uint256

func (i *Number) Uint256() *Number

Returns the unsigned version of i

func (*Number) Uint64

func (i *Number) Uint64() uint64

Uint64 returns the Uint64 representation of x. If x cannot be represented in an int64, the result is undefined.

Jump to

Keyboard shortcuts

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