Generated on Thu Jan 16 2025 00:00:00 for Gecode by doxygen 1.14.0

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

◆ valid() [1/2]

bool Gecode::Int::Limits::valid ( int n)
inline

Return whether n is in range.

Definition at line 37 of file limits.hpp.

◆ valid() [2/2]

bool Gecode::Int::Limits::valid ( long long int n)
inline

Return whether n is in range.

Definition at line 41 of file limits.hpp.

◆ check() [1/2]

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 46 of file limits.hpp.

◆ check() [2/2]

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 51 of file limits.hpp.

◆ positive() [1/2]

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 57 of file limits.hpp.

◆ positive() [2/2]

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 62 of file limits.hpp.

◆ nonnegative() [1/2]

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 68 of file limits.hpp.

◆ nonnegative() [2/2]

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 73 of file limits.hpp.

◆ overflow_add() [1/2]

bool Gecode::Int::Limits::overflow_add ( int n,
int m )
inline

Check whether adding n and m would overflow.

Definition at line 79 of file limits.hpp.

◆ overflow_add() [2/2]

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 85 of file limits.hpp.

◆ overflow_sub() [1/2]

bool Gecode::Int::Limits::overflow_sub ( int n,
int m )
inline

Check whether subtracting m from n would overflow.

Definition at line 93 of file limits.hpp.

◆ overflow_sub() [2/2]

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 99 of file limits.hpp.

◆ overflow_mul() [1/2]

bool Gecode::Int::Limits::overflow_mul ( int n,
int m )
inline

Check whether multiplying n and m would overflow.

Definition at line 107 of file limits.hpp.

◆ overflow_mul() [2/2]

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 114 of file limits.hpp.

Variable Documentation

◆ max

const int Gecode::Int::Limits::max = INT_MAX - 1

Largest allowed integer value.

Definition at line 116 of file int.hh.

◆ min

const int Gecode::Int::Limits::min = -max

Smallest allowed integer value.

Definition at line 118 of file int.hh.

◆ infinity

const int Gecode::Int::Limits::infinity = max + 1

Infinity for integers.

Definition at line 120 of file int.hh.

◆ llmax

const long long int Gecode::Int::Limits::llmax = LLONG_MAX - 1

Largest allowed long long integer value.

Definition at line 122 of file int.hh.

◆ llmin

const long long int Gecode::Int::Limits::llmin = -llmax

Smallest allowed long long integer value.

Definition at line 124 of file int.hh.

◆ llinfinity

const long long int Gecode::Int::Limits::llinfinity = llmax + 1

Infinity for long long integers.

Definition at line 126 of file int.hh.