math
Package math
import "github.com/luxfi/node/utils/math"Functions
AbsDiff
func AbsDiff[T Unsigned](a, b T) TAdd
func Add[T Unsigned](a, b T) (T, error)Add returns:
- a + b
- If there is overflow, an error
MaxUint
func MaxUint[T Unsigned]() TMaxUint returns the maximum value of an unsigned integer of type T.
Mul
func Mul[T Unsigned](a, b T) (T, error)Mul returns:
- a * b
- If there is overflow, an error
Sub
func Sub[T Unsigned](a, b T) (T, error)Sub returns:
- a - b
- If there is underflow, an error
Types
Averager
Averager tracks a continuous time exponential moving average of the provided values.
func NewAverager(
initialPrediction float64,
halflife time.Duration,
currentTime time.Time,
) Averagerfunc NewSyncAverager(averager Averager) Averagerfunc NewUninitializedAverager(halfLife time.Duration) AveragerAveragerHeap
AveragerHeap maintains a heap of the averagers.
func NewMaxAveragerHeap() AveragerHeapUnsigned
Unsigned is a constraint that permits any unsigned integer type.