slang/numeric/MathUtils.h file

Various math utilities.

Namespaces

namespace slang
Root namespace.

Functions

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