cost

package
v0.32.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2026 License: Apache-2.0, BSD-3-Clause Imports: 1 Imported by: 0

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 SafeAdd

func SafeAdd(x, y uint64, rest ...uint64) uint64

SafeAdd returns the sum of the input values, saturating at math.MaxUint64.

func SafeCeil

func SafeCeil(x float64) uint64

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

func SafeMultiply(x, y uint64) uint64

SafeMultiply returns the product of the input values, saturating at math.MaxUint64.

func SafeMultiplyByFactor

func SafeMultiplyByFactor(x uint64, factor float64) uint64

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL