38 return ((n >=
min) && (n <=
max));
42 return ((n >=
min) && (n <=
max));
47 if ((n <
min) || (n >
max))
52 if ((n <
min) || (n >
max))
58 if ((n <= 0) || (n >
max))
63 if ((n <= 0.0) || (n >
max))
69 if ((n < 0) || (n >
max))
74 if ((n < 0.0) || (n >
max))
81 static_cast<long long int>(n) +
static_cast<long long int>(m);
82 return (nm > INT_MAX) || (nm < INT_MIN+1);
87 return n < LLONG_MIN + 1 - m;
89 return n > LLONG_MAX - m;
95 static_cast<long long int>(n) -
static_cast<long long int>(m);
96 return (nm > INT_MAX) || (nm < INT_MIN+1);
101 return n > LLONG_MAX + m;
103 return n < LLONG_MIN + 1 + m;
109 static_cast<long long int>(n) *
static_cast<long long int>(m);
110 return (nm > INT_MAX) || (nm < INT_MIN+1);
116 if ((n == LLONG_MIN) || (m == LLONG_MIN))
119 unsigned long long int un =
120 static_cast<unsigned long long int>(n < 0 ? -n : n);
121 unsigned long long int um =
122 static_cast<unsigned long long int>(m < 0 ? -m : m);
124 const unsigned int k = CHAR_BIT *
sizeof(int);
126 unsigned long long int un_hi = un >> k;
127 unsigned long long int un_lo = un & ((1ULL << k) - 1ULL);
128 unsigned long long int um_hi = um >> k;
129 unsigned long long int um_lo = um & ((1ULL << k) - 1ULL);
132 if ((un_hi != 0ULL) && (um_hi != 0ULL))
135 unsigned long long int unm_hi = 0ULL;
139 unm_hi = un_hi * um_lo;
140 else if (um_hi != 0ULL)
141 unm_hi = um_hi * un_lo;
146 if ((unm_hi >> k) != 0ULL)
150 unsigned long long int unm_lo = un_lo * um_lo;
152 return unm_hi >
static_cast<unsigned long long int>(LLONG_MAX) - unm_lo;
Exception: Value out of limits
void positive(int n, const char *l)
Check whether n is in range and strictly positive, otherwise throw out of limits with information l.
bool overflow_add(int n, int m)
Check whether adding n and m would overflow.
void nonnegative(int n, const char *l)
Check whether n is in range and nonnegative, otherwise throw out of limits with information l.
void check(int n, const char *l)
Check whether n is in range, otherwise throw out of limits with information l.
bool overflow_mul(int n, int m)
Check whether multiplying n and m would overflow.
const int min
Smallest allowed integer value.
bool valid(int n)
Return whether n is in range.
const int max
Largest allowed integer value.
bool overflow_sub(int n, int m)
Check whether subtracting m from n would overflow.
Gecode toplevel namespace