safemath

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SafeUintZero = (*SafeUint256)(big.NewInt(0))
	// SafeUintOne is 1
	SafeUintOne    = (*SafeUint256)(big.NewInt(1))
	MaxSafeUint256 *SafeUint256
)

Functions

This section is empty.

Types

type SafeUint256

type SafeUint256 big.Int

SafeUint256 calculation uint256

func NewSafeUint256 added in v1.0.1

func NewSafeUint256(i uint64) *SafeUint256

NewSafeUint256 SafeUint256 constructor @param i @return *SafeUint256

func ParseSafeUint256

func ParseSafeUint256(x string) (*SafeUint256, bool)

ParseSafeUint256 get uint256 obj from str

func SafeAdd

func SafeAdd(x, y *SafeUint256) (*SafeUint256, bool)

SafeAdd sets z to the sum x+y and returns z.

func SafeDiv

func SafeDiv(x, y *SafeUint256) *SafeUint256

SafeDiv sets z to the quotient x/y for y != 0 and returns z. If y == 0, a division-by-zero run-time panic occurs. Div implements Euclidean division (unlike Go); see DivMod for more details.

func SafeMul

func SafeMul(x, y *SafeUint256) (*SafeUint256, bool)

SafeMul sets z to the product x*y and returns z.

func SafeSub

func SafeSub(x, y *SafeUint256) (*SafeUint256, bool)

SafeSub sets z to the difference x-y and returns z.

func (*SafeUint256) Cmp

func (x *SafeUint256) Cmp(y *SafeUint256) int

Cmp compares x and y and returns:

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

func (*SafeUint256) Equal added in v1.0.1

func (x *SafeUint256) Equal(y *SafeUint256) bool

Equal if x==y return true @param y @return bool

func (*SafeUint256) GTE added in v1.0.1

func (x *SafeUint256) GTE(y *SafeUint256) bool

GTE if x>=y return true

func (*SafeUint256) IsMaxSafeUint256

func (x *SafeUint256) IsMaxSafeUint256() bool

IsMaxSafeUint256 return is maxUint256

func (*SafeUint256) ToString

func (x *SafeUint256) ToString() string

ToString get str from uint256

Jump to

Keyboard shortcuts

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