safemath

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type SafeUint256

type SafeUint256 big.Int

SafeUint256 calculation uint256

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