slang/numeric/MathUtils.h file

Various math utilities.

Namespaces

namespace slang
Root namespace.

Functions

std::optional<int32_t> checkedAddS32(int32_t a, int32_t b)
Performs an addition of two signed 32-bit integers and returns the result if it does not overflow.
std::optional<int32_t> checkedSubS32(int32_t a, int32_t b)
Performs a subtraction of two signed 32-bit integers and returns the result if it does not overflow.
std::optional<uint32_t> checkedMulU32(uint32_t a, uint32_t b)
Performs a multiplication of two unsigned 32-bit integers and returns the result if it does not overflow.
std::optional<uint64_t> checkedMulU64(uint64_t a, uint64_t b)
Performs a multiplication of two unsigned 64-bit integers and returns the result if it does not overflow.