Documentation
¶
Overview ¶
Package cost provides the saturating arithmetic shared by cost estimation and cost tracking.
Costs and sizes are unsigned 64-bit values where math.MaxUint64 doubles as the representation of an unbounded, or unknown, quantity. Every operation in this package saturates at math.MaxUint64 rather than wrapping so that an unbounded input remains unbounded through any sequence of operations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SafeCeil ¶
SafeCeil returns the smallest integer value greater than or equal to the input, saturating at math.MaxUint64 and flooring at zero.
Negative and NaN inputs return zero.
func SafeMultiply ¶
SafeMultiply returns the product of the input values, saturating at math.MaxUint64.
func SafeMultiplyByFactor ¶
SafeMultiplyByFactor multiplies a value by a cost factor and returns the nearest integer value, rounded up, saturating at math.MaxUint64.
Types ¶
This section is empty.