Documentation
¶
Index ¶
- Variables
- func AddBigFloat(op1, op2 *big.Float) (result *big.Float, err error)
- func AddInt32(a, b int32) int32
- func AddInt32WithErr(a, b int32) (int32, error)
- func AddUint64(a, b uint64) uint64
- func AddUint64WithErr(a, b uint64) (uint64, error)
- func CheckBoundsInt32(start, length int32, maxLen int) error
- func MulBigFloat(op1, op2 *big.Float) (result *big.Float, err error)
- func MulInt32(a, b int32) int32
- func MulInt32WithErr(a, b int32) (int32, error)
- func MulUint64(a, b uint64) uint64
- func MulUint64WithErr(a, b uint64) (uint64, error)
- func NewOverflowHandler() *overflowHandler
- func NewSeedRandReader(seed []byte) *seedRandReader
- func QuoBigFloat(op1, op2 *big.Float) (result *big.Float, err error)
- func SqrtBigFloat(op *big.Float) (result *big.Float, err error)
- func SubBigFloat(op1, op2 *big.Float) (result *big.Float, err error)
- func SubInt(a, b int) int
- func SubInt32(a, b int32) int32
- func SubInt32WithErr(a, b int32) (int32, error)
- func SubUint64(a, b uint64) uint64
- func SubUint64WithErr(a, b uint64) (uint64, error)
- func TwosComplementByteLength(bi *big.Int) int
- func UnsignedByteLength(bi *big.Int) int
- type RandomnessGenerator
Constants ¶
This section is empty.
Variables ¶
var ErrAdditionOverflow = errors.New("addition overflow")
ErrAdditionOverflow is raised when there is an overflow because of the addition of two numbers
var ErrBigFloatAdd = errors.New("this big Float operation is not permitted while doing float.Add")
ErrBigFloatAdd is raised when add of floats produces a panic
var ErrBigFloatMul = errors.New("this big Float operation is not permitted while doing float.Mul")
ErrBigFloatMul is raised when mul of floats produces a panic
var ErrBigFloatQuo = errors.New("this big Float operation is not permitted while doing float.Quo")
ErrBigFloatQuo is raised when quo of floats produces a panic
var ErrBigFloatSqrt = errors.New("this big Float operation is not permitted while doing float.Sqrt")
ErrBigFloatSqrt is raised when sqrt of floats produces a panic
var ErrBigFloatSub = errors.New("this big Float operation is not permitted while doing float.Sub")
ErrBigFloatSub is raised when sub of floats produces a panic
var ErrMultiplicationOverflow = errors.New("multiplication overflow")
ErrMultiplicationOverflow is raised when there is an overflow because of the multiplication of two numbers
var ErrOutOfBounds = errors.New("out of bounds")
ErrOutOfBounds is raised when slice start or length exceeds bounds
var ErrSubtractionUnderflow = errors.New("subtraction underflow")
ErrSubtractionUnderflow is raised when there is an underflow because of the subtraction of two numbers
Functions ¶
func AddBigFloat ¶
AddBigFloat addition implementation with error handling for big float
func AddInt32WithErr ¶ added in v1.5.6
AddInt32WithErr performs addition on int32 and returns an error if the addition overflows
func AddUint64WithErr ¶
AddUint64WithErr performs addition on uint64 and returns an error if the addition overflows
func CheckBoundsInt32 ¶ added in v1.5.52
CheckBoundsInt32 validates that start and length are non-negative and int64(start)+int64(length) <= int64(maxLen)
func MulBigFloat ¶
MulBigFloat multiplication implementation with error handling for big float
func MulInt32 ¶ added in v1.5.47
MulInt32 performs multiplication on int32 and logs an error if the multiplication overflows
func MulInt32WithErr ¶ added in v1.5.47
MulInt32WithErr performs multiplication on int32 and returns an error if the multiplication overflows
func MulUint64 ¶
MulUint64 performs multiplication on uint64 and logs an error if the multiplication overflows
func MulUint64WithErr ¶
MulUint64WithErr performs multiplication on uint64 and returns an error if the multiplication overflows
func NewOverflowHandler ¶ added in v1.5.6
func NewOverflowHandler() *overflowHandler
NewOverflowHandler creates a new instance of type overflowHandler This struct is not concurrent safe and should be instantiated for each chain of operations required to be executed
func NewSeedRandReader ¶
func NewSeedRandReader(seed []byte) *seedRandReader
NewSeedRandReader creates and returns a new SeedRandReader
func QuoBigFloat ¶
QuoBigFloat quotient implementation with error handling for big float
func SqrtBigFloat ¶
SqrtBigFloat sqrt implementation with error handling for big float
func SubBigFloat ¶
SubBigFloat subtraction implementation with error handling for big float
func SubInt32 ¶ added in v1.5.52
SubInt32 performs subtraction on int32 and logs an error if the subtraction underflows
func SubInt32WithErr ¶ added in v1.5.52
SubInt32WithErr performs subtraction on int32 and returns an error if the subtraction underflows or overflows
func SubUint64WithErr ¶ added in v1.5.52
SubUint64WithErr performs subtraction on uint64 and returns an error if the subtraction underflows
func TwosComplementByteLength ¶ added in v1.5.52
TwosComplementByteLength returns the number of bytes that the two's complement representation of the given value occupies, i.e. len(twos.ToBytes(bi)), without allocating or building that representation.
The length is derived from the bit length alone:
- zero is encoded on 0 bytes;
- a positive value needs BitLen() bits plus one sign bit that must be 0, hence BitLen()/8 + 1 bytes;
- a negative value -a is encoded as the bit-negation of a-1 plus a sign bit that must be 1, hence BitLen(a-1)/8 + 1 bytes. BitLen(a-1) equals BitLen(a), except when a is an exact power of two, when it is one less.
TODO: move to mx-components-big-int/twos-complement after the next VM release.
func UnsignedByteLength ¶ added in v1.5.52
UnsignedByteLength returns the number of bytes that the absolute value of the given big int occupies, i.e. len(bi.Bytes()), without allocating those bytes.
Note that, just like big.Int.Bytes, this disregards the sign.