math

package
v0.0.0-...-77dcbbd Latest Latest
Warning

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

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

Documentation

Overview

Package math provides safe math operations for blockchain usage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SafeAdd

func SafeAdd(x, y uint64) (uint64, bool)

SafeAdd returns x+y and checks for overflow.

func SafeMul

func SafeMul(x, y uint64) (uint64, bool)

SafeMul returns x*y and checks for overflow.

func SafeSub

func SafeSub(x, y uint64) (uint64, bool)

SafeSub returns x-y and checks for overflow.

func SafeSubWithMin

func SafeSubWithMin[T UInt](x, y, min T) T

SubWithMin returns x - y and return min if less than zero.

Types

type UInt

type UInt interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64
}

Jump to

Keyboard shortcuts

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