Gecode::Int::Limits Namespace Reference
[Integer variables]
Numerical limits for integer variables. More...
Functions | |
bool | valid (int n) |
Return whether n is in range. | |
bool | valid (long long int n) |
Return whether n is in range. | |
void | check (int n, const char *l) |
Check whether n is in range, otherwise throw out of limits with information l. | |
void | check (long long 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. | |
void | positive (long long int n, const char *l) |
Check whether n is in range and strictly positive, otherwise throw out of limits with information l. | |
void | nonnegative (int n, const char *l) |
Check whether n is in range and nonnegative, otherwise throw out of limits with information l. | |
void | nonnegative (long long int n, const char *l) |
Check whether n is in integer range and nonnegative, otherwise throw out of limits exception with information l. | |
bool | overflow_add (int n, int m) |
Check whether adding n and m would overflow. | |
bool | overflow_add (long long int n, long long int m) |
Check whether adding n and m would overflow. | |
bool | overflow_sub (int n, int m) |
Check whether subtracting m from n would overflow. | |
bool | overflow_sub (long long int n, long long int m) |
Check whether subtracting m from n would overflow. | |
bool | overflow_mul (int n, int m) |
Check whether multiplying n and m would overflow. | |
bool | overflow_mul (long long int n, long long int m) |
Check whether multiplying n and m would overflow. | |
Variables | |
const int | max = INT_MAX - 1 |
Largest allowed integer value. | |
const int | min = -max |
Smallest allowed integer value. | |
const int | infinity = max + 1 |
Infinity for integers. | |
const long long int | llmax = LLONG_MAX - 1 |
Largest allowed long long integer value. | |
const long long int | llmin = -llmax |
Smallest allowed long long integer value. | |
const long long int | llinfinity = llmax + 1 |
Infinity for long long integers. |
Detailed Description
Numerical limits for integer variables.
The integer limits are chosen such changing the sign is always possible without overflow.
Function Documentation
bool Gecode::Int::Limits::valid | ( | int | n | ) | [inline] |
Return whether n is in range.
Definition at line 41 of file limits.hpp.
bool Gecode::Int::Limits::valid | ( | long long int | n | ) | [inline] |
Return whether n is in range.
Definition at line 45 of file limits.hpp.
void Gecode::Int::Limits::check | ( | int | n, | |
const char * | l | |||
) | [inline] |
Check whether n is in range, otherwise throw out of limits with information l.
Definition at line 50 of file limits.hpp.
void Gecode::Int::Limits::check | ( | long long int | n, | |
const char * | l | |||
) | [inline] |
Check whether n is in range, otherwise throw out of limits with information l.
Definition at line 55 of file limits.hpp.
void Gecode::Int::Limits::positive | ( | int | n, | |
const char * | l | |||
) | [inline] |
Check whether n is in range and strictly positive, otherwise throw out of limits with information l.
Definition at line 61 of file limits.hpp.
void Gecode::Int::Limits::positive | ( | long long int | n, | |
const char * | l | |||
) | [inline] |
Check whether n is in range and strictly positive, otherwise throw out of limits with information l.
Definition at line 66 of file limits.hpp.
void Gecode::Int::Limits::nonnegative | ( | int | n, | |
const char * | l | |||
) | [inline] |
Check whether n is in range and nonnegative, otherwise throw out of limits with information l.
Definition at line 72 of file limits.hpp.
void Gecode::Int::Limits::nonnegative | ( | long long int | n, | |
const char * | l | |||
) | [inline] |
Check whether n is in integer range and nonnegative, otherwise throw out of limits exception with information l.
Definition at line 77 of file limits.hpp.
bool Gecode::Int::Limits::overflow_add | ( | int | n, | |
int | m | |||
) | [inline] |
Check whether adding n and m would overflow.
Definition at line 83 of file limits.hpp.
bool Gecode::Int::Limits::overflow_add | ( | long long int | n, | |
long long int | m | |||
) | [inline] |
Check whether adding n and m would overflow.
Definition at line 89 of file limits.hpp.
bool Gecode::Int::Limits::overflow_sub | ( | int | n, | |
int | m | |||
) | [inline] |
Check whether subtracting m from n would overflow.
Definition at line 97 of file limits.hpp.
bool Gecode::Int::Limits::overflow_sub | ( | long long int | n, | |
long long int | m | |||
) | [inline] |
Check whether subtracting m from n would overflow.
Definition at line 103 of file limits.hpp.
bool Gecode::Int::Limits::overflow_mul | ( | int | n, | |
int | m | |||
) | [inline] |
Check whether multiplying n and m would overflow.
Definition at line 111 of file limits.hpp.
bool Gecode::Int::Limits::overflow_mul | ( | long long int | n, | |
long long int | m | |||
) | [inline] |
Check whether multiplying n and m would overflow.
Definition at line 118 of file limits.hpp.
Variable Documentation
const int Gecode::Int::Limits::max = INT_MAX - 1 |
const int Gecode::Int::Limits::min = -max |
const int Gecode::Int::Limits::infinity = max + 1 |
const long long int Gecode::Int::Limits::llmax = LLONG_MAX - 1 |
const long long int Gecode::Int::Limits::llmin = -llmax |
const long long int Gecode::Int::Limits::llinfinity = llmax + 1 |