number

package
v1.0.1-0...-124d54e Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2018 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

Initialiser is a Number function

func NewInitialiser

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

NewInitialiser 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

Big returns a Number with a SIGNED unlimited size

func Int256

func Int256(n int64) *Number

Int256 returns Number with a SIGNED limiter up to 256 bits

func Uint256

func Uint256(n int64) *Number

Uint256 returns a Number with a UNSIGNED limiter up to 256 bits

func (*Number) Add

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

Add sets i to sum of x+y

func (*Number) Bytes

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

Bytes 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

Div sets i to the quotient prodject of x/y

func (*Number) FirstBitSet

func (i *Number) FirstBitSet() int

FirstBitSet returns the index of the first bit that's set to 1

func (*Number) Int256

func (i *Number) Int256() *Number

Int256 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

Lsh sets i to x << s

func (*Number) Mod

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

Mod sets i to x % y

func (*Number) Mul

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

Mul sets i to product of x*y

func (*Number) Pow

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

Pow sets i to x^y

func (*Number) Set

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

Set sets x to i

func (*Number) SetBytes

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

SetBytes sets x bytes to i

func (*Number) String

func (i *Number) String() string

String returns the string representation of i

func (*Number) Sub

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

Sub sets i to difference of x-y

func (*Number) Uint256

func (i *Number) Uint256() *Number

Uint256 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