38 namespace Gecode {
namespace Int {
42 return ((n >=
min) && (n <=
max));
46 return ((n >=
min) && (n <=
max));
51 if ((n <
min) || (n >
max))
56 if ((n <
min) || (n >
max))
62 if ((n <= 0) || (n >
max))
67 if ((n <= 0.0) || (n >
max))
73 if ((n < 0) || (n >
max))
78 if ((n < 0.0) || (n >
max))
85 static_cast<long long int>(
n) + static_cast<long long int>(m);
86 return (nm > INT_MAX) || (nm < INT_MIN+1);
91 return n < LLONG_MIN + 1 - m;
93 return n > LLONG_MAX - m;
99 static_cast<long long int>(
n) - static_cast<long long int>(m);
100 return (nm > INT_MAX) || (nm < INT_MIN+1);
105 return n > LLONG_MAX + m;
107 return n < LLONG_MIN + 1 + m;
113 static_cast<long long int>(
n) * static_cast<long long int>(m);
114 return (nm > INT_MAX) || (nm < INT_MIN+1);
120 if ((n == LLONG_MIN) || (m == LLONG_MIN))
123 unsigned long long int un =
124 static_cast<unsigned long long int>(n < 0 ? -n :
n);
125 unsigned long long int um =
126 static_cast<unsigned long long int>(m < 0 ? -m : m);
128 const unsigned int k = CHAR_BIT *
sizeof(int);
130 unsigned long long int un_hi = un >> k;
131 unsigned long long int un_lo = un & ((1ULL << k) - 1ULL);
132 unsigned long long int um_hi = um >> k;
133 unsigned long long int um_lo = um & ((1ULL << k) - 1ULL);
136 if ((un_hi != 0ULL) && (um_hi != 0ULL))
139 unsigned long long int unm_hi = 0ULL;
143 unm_hi = un_hi * um_lo;
144 else if (um_hi != 0ULL)
145 unm_hi = um_hi * un_lo;
150 if ((unm_hi >> k) != 0ULL)
154 unsigned long long int unm_lo = un_lo * um_lo;
156 return unm_hi >
static_cast<unsigned long long int>(LLONG_MAX) - unm_lo;
Exception: Value out of limits
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
void nonnegative(int n, const char *l)
Check whether n is in range and nonnegative, otherwise throw out of limits with information l...
bool overflow_mul(int n, int m)
Check whether multiplying n and m would overflow.
int n
Number of negative literals for node type.
bool overflow_add(int n, int m)
Check whether adding n and m would overflow.
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
bool overflow_sub(int n, int m)
Check whether subtracting m from n would overflow.
bool valid(int n)
Return whether n is in range.
Gecode toplevel namespace
void check(int n, const char *l)
Check whether n is in range, otherwise throw out of limits with information l.
void positive(int n, const char *l)
Check whether n is in range and strictly positive, otherwise throw out of limits with information l...