tendermint: github.com/tendermint/tendermint/libs/math Index | Files

package math

import "github.com/tendermint/tendermint/libs/math"

Index

Package Files

fraction.go math.go safemath.go

Variables

var ErrOverflowInt32 = errors.New("int32 overflow")
var ErrOverflowInt8 = errors.New("int8 overflow")
var ErrOverflowUint8 = errors.New("uint8 overflow")

func MaxInt Uses

func MaxInt(a, b int) int

func MaxInt64 Uses

func MaxInt64(a, b int64) int64

func MinInt Uses

func MinInt(a, b int) int

func MinInt64 Uses

func MinInt64(a, b int64) int64

func SafeAddInt32 Uses

func SafeAddInt32(a, b int32) int32

SafeAddInt32 adds two int32 integers If there is an overflow this will panic

func SafeConvertInt32 Uses

func SafeConvertInt32(a int64) int32

SafeConvertInt32 takes a int and checks if it overflows If there is an overflow this will panic

func SafeConvertInt8 Uses

func SafeConvertInt8(a int64) (int8, error)

SafeConvertInt8 takes an int64 and checks if it overflows If there is an overflow it returns an error

func SafeConvertUint8 Uses

func SafeConvertUint8(a int64) (uint8, error)

SafeConvertUint8 takes an int64 and checks if it overflows If there is an overflow it returns an error

func SafeSubInt32 Uses

func SafeSubInt32(a, b int32) int32

SafeSubInt32 subtracts two int32 integers If there is an overflow this will panic

type Fraction Uses

type Fraction struct {
    // The portion of the denominator in the faction, e.g. 2 in 2/3.
    Numerator int64 `json:"numerator"`
    // The value by which the numerator is divided, e.g. 3 in 2/3. Must be
    // positive.
    Denominator int64 `json:"denominator"`
}

Fraction defined in terms of a numerator divided by a denominator in int64 format.

func (Fraction) String Uses

func (fr Fraction) String() string

Package math imports 3 packages (graph) and is imported by 14 packages. Updated 2020-06-30. Refresh now. Tools for package owners.