Documentation ¶
Overview ¶
Package mathutil includes important helpers for eth2 such as fast integer square roots.
Index ¶
- func Add64(a, b uint64) (uint64, error)
- func CeilDiv8(n int) int
- func ClosestPowerOf2(n uint64) uint64
- func IntegerSquareRoot(n uint64) uint64
- func IsPowerOf2(n uint64) bool
- func Max(a, b uint64) uint64
- func Min(a, b uint64) uint64
- func Mul64(a, b uint64) (uint64, error)
- func PowerOf2(n uint64) uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add64 ¶ added in v1.0.0
Add64 adds 2 64-bit unsigned integers and checks if they lead to an overflow. If they do not, it returns the result without an error.
func ClosestPowerOf2 ¶
ClosestPowerOf2 returns an integer that is the closest power of 2 that is less than or equal to the argument.
func IntegerSquareRoot ¶
IntegerSquareRoot defines a function that returns the largest possible integer root of a number using go's standard library.
func IsPowerOf2 ¶
IsPowerOf2 returns true if n is an exact power of two. False otherwise.
func Max ¶
Max returns the larger integer of the two given ones.This is used over the Max function in the standard math library because that max function has to check for some special floating point cases making it slower by a magnitude of 10.
func Min ¶
Min returns the smaller integer of the two given ones. This is used over the Min function in the standard math library because that min function has to check for some special floating point cases making it slower by a magnitude of 10.
Types ¶
This section is empty.