#include <infty_int.hh>
Public Types | |
typedef long int | base_type |
the base type | |
Public Member Functions | |
TaintedInftyInt () | |
Construct empty. | |
TaintedInftyInt (const base_type &x) | |
Construct from base type. | |
bool | is_neg_infty () const |
bool | is_pos_infty () const |
bool | is_finite () const |
bool | is_normal () const |
base_type | finite_value () const |
Convert finite value to base type. | |
TaintedInftyInt & | operator= (const FiniteInt &x) |
Assignment. | |
Static Public Member Functions | |
static base_type | min_finite () |
minimum finite value | |
static base_type | max_finite () |
maximum finite value | |
Protected Attributes | |
base_type | val |
value | |
Static Protected Attributes | |
static const base_type | min_finity |
minimum finite value | |
static const base_type | max_finity |
maximum finite value | |
static const base_type | min_normal_neg_infty |
minimum normal infinite value | |
static const base_type | max_normal_pos_infty |
maximum normal infinite value | |
Friends | |
class | InftyInt |
bool | operator== (const TaintedInftyInt &x, const TaintedInftyInt &y) |
Equality test. | |
TaintedInftyInt | operator+ (const TaintedInftyInt &x, const FiniteInt &y) |
Add. | |
TaintedInftyInt | operator- (const TaintedInftyInt &x, const FiniteInt &y) |
Subtract. | |
TaintedInftyInt | operator+ (const InftyInt &x, const InftyInt &y) |
Add. | |
TaintedInftyInt | operator- (const InftyInt &x, const InftyInt &y) |
Subtract. | |
TaintedInftyInt | min (const TaintedInftyInt &x, const TaintedInftyInt &y) |
Minimum. | |
TaintedInftyInt | max (const TaintedInftyInt &x, const TaintedInftyInt &y) |
Maximum. | |
bool | operator> (const TaintedInftyInt &x, const TaintedInftyInt &y) |
bool | operator< (const TaintedInftyInt &x, const TaintedInftyInt &y) |
bool | operator>= (const TaintedInftyInt &x, const TaintedInftyInt &y) |
bool | operator<= (const TaintedInftyInt &x, const TaintedInftyInt &y) |
std::ostream & | operator<< (std::ostream &out, const TaintedInftyInt &x) |
Potentially infinite value where finite values are integer. In contrast to class NormInfyInt, the representation of infinity can be denormalized, this means that it is not safe (and therefore not supported) to subtract or add a second potentially infinite value. In general, such non-normalized potentially infinite integers are produced as results of adding/subtracting normal potentially infinite integers.
The infinity integer classes TaintedInftyInt, InftyInt and FiniteInt support efficient addition and minimization/maximization of potentially infinite integer values. For this purpose, the range of the base type (long int) is restricted. With this encoding, two normal infinite values (InftyInt) of the same sign can be added without resulting in overflow. This yields a non-normal TaintedInftyInt, which still allows to add finite integers (FiniteInt) without overflow (at least as long as the added finite integers do not exceed the remaining range of [-m..m-1]), where m=2^(s-1) and s is the width of the base type, e.g. 64.
The range of the base type is split into subranges, where s is the number of bits in the base type:
negative infinity [ -m..-m/5 [ normal negative infinity [ -3m/5..-m/5 [ normalized negative infinity -2m/5 finite range [ -m/5 .. m/5 [ normal positive infinity [ m/5 .. 3m/5 [ normalized positive infinity 2m/5 positive infinity [ m/5 .. m [
Normalizing resets negative infinite values to -2m/5 and positive infinite values to 2m/5. In this way, adding two normalized infinite values of the same sign and some finite value using fast standard integer addition always works without overflow and results in a defined value in the infinite range.
LocARNA::TaintedInftyInt::TaintedInftyInt | ( | const base_type & | x | ) | [inline, explicit] |
Construct from base type.
x | base type value |
base_type LocARNA::TaintedInftyInt::finite_value | ( | ) | const [inline] |
Convert finite value to base type.
Reimplemented in LocARNA::FiniteInt.
bool LocARNA::TaintedInftyInt::is_finite | ( | ) | const [inline] |
Test for finite
bool LocARNA::TaintedInftyInt::is_neg_infty | ( | ) | const [inline] |
Test for negative infinity
bool LocARNA::TaintedInftyInt::is_normal | ( | ) | const [inline] |
Test for finite or normal infinity
bool LocARNA::TaintedInftyInt::is_pos_infty | ( | ) | const [inline] |
Test for positive infinity
static base_type LocARNA::TaintedInftyInt::max_finite | ( | ) | [inline, static] |
maximum finite value
static base_type LocARNA::TaintedInftyInt::min_finite | ( | ) | [inline, static] |
minimum finite value
TaintedInftyInt & LocARNA::TaintedInftyInt::operator= | ( | const FiniteInt & | x | ) | [inline] |
Assignment.
x | finite int to be assigned |
TaintedInftyInt max | ( | const TaintedInftyInt & | x, |
const TaintedInftyInt & | y | ||
) | [friend] |
Maximum.
x | operand 1 |
y | operand 2 |
TaintedInftyInt min | ( | const TaintedInftyInt & | x, |
const TaintedInftyInt & | y | ||
) | [friend] |
Minimum.
x | operand 1 |
y | operand 2 |
TaintedInftyInt operator+ | ( | const TaintedInftyInt & | x, |
const FiniteInt & | y | ||
) | [friend] |
Add.
x | operand 1 |
y | operand 2 |
TaintedInftyInt operator+ | ( | const InftyInt & | x, |
const InftyInt & | y | ||
) | [friend] |
Add.
x | operand 1 |
y | operand 2 |
TaintedInftyInt operator- | ( | const TaintedInftyInt & | x, |
const FiniteInt & | y | ||
) | [friend] |
Subtract.
x | operand 1 |
y | operand 2 |
TaintedInftyInt operator- | ( | const InftyInt & | x, |
const InftyInt & | y | ||
) | [friend] |
Subtract.
x | operand 1 |
y | operand 2 |
bool operator< | ( | const TaintedInftyInt & | x, |
const TaintedInftyInt & | y | ||
) | [friend] |
Less than operator
x | operand 1 |
y | operand 2 |
std::ostream& operator<< | ( | std::ostream & | out, |
const TaintedInftyInt & | x | ||
) | [friend] |
Write TaintedInftyInt object to stream
out | output stream |
x | object |
Output operator for writing object of TaintedInftyInt to output stream
out | the output stream |
x | the object to be written |
bool operator<= | ( | const TaintedInftyInt & | x, |
const TaintedInftyInt & | y | ||
) | [friend] |
Less or equal than operator
x | operand 1 |
y | operand 2 |
bool operator== | ( | const TaintedInftyInt & | x, |
const TaintedInftyInt & | y | ||
) | [friend] |
Equality test.
x | operand 1 (tainted) |
y | operand 2 (tainted) |
bool operator> | ( | const TaintedInftyInt & | x, |
const TaintedInftyInt & | y | ||
) | [friend] |
Greater than operator
x | operand 1 |
y | operand 2 |
bool operator>= | ( | const TaintedInftyInt & | x, |
const TaintedInftyInt & | y | ||
) | [friend] |
Greater or equal than operator
x | operand 1 |
y | operand 2 |
const TaintedInftyInt::base_type LocARNA::TaintedInftyInt::max_finity [static, protected] |
-(std::numeric_limits<TaintedInftyInt::base_type>::min() / 5) - 1
maximum finite value
const TaintedInftyInt::base_type LocARNA::TaintedInftyInt::max_normal_pos_infty [static, protected] |
-(std::numeric_limits<TaintedInftyInt::base_type>::min() / 5 * 3) - 1
maximum normal infinite value
const TaintedInftyInt::base_type LocARNA::TaintedInftyInt::min_finity [static, protected] |
minimum finite value
const TaintedInftyInt::base_type LocARNA::TaintedInftyInt::min_normal_neg_infty [static, protected] |
minimum normal infinite value