4#ifndef BITCOIN_SCRIPT_INTMATH_H
5#define BITCOIN_SCRIPT_INTMATH_H
16 if (
a > 0 &&
b > std::numeric_limits<int64_t>::max() -
a) {
20 if (
a < 0 &&
b <= std::numeric_limits<int64_t>::min() -
a) {
25 return result == std::numeric_limits<int64_t>::min();
35#if HAVE_DECL___BUILTIN_SADDLL_OVERFLOW
39 return result == std::numeric_limits<int64_t>::min();
55 if (
a > 0 &&
b <= std::numeric_limits<int64_t>::min() +
a) {
60 return result == std::numeric_limits<int64_t>::min();
70#if HAVE_DECL___BUILTIN_SSUBLL_OVERFLOW
74 return result == std::numeric_limits<int64_t>::min();
static bool AddInt63Overflow(int64_t a, int64_t b, int64_t &result)
Computes a + b and stores it in result.
static bool AddInt63OverflowEmulated(int64_t a, int64_t b, int64_t &result)
Computes a + b and stores it in result.
static bool SubInt63Overflow(int64_t a, int64_t b, int64_t &result)
Computes a - b and stores it in result.
static bool SubInt63OverflowEmulated(int64_t a, int64_t b, int64_t &result)
Computes a - b and stores it in result.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...