LocARNA-2.0.0
|
#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. More... | |
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. More... | |
TaintedInftyInt & | operator= (const FiniteInt &x) |
Assignment. More... | |
Static Public Member Functions | |
static base_type | min_finite () |
minimum finite value More... | |
static base_type | max_finite () |
maximum finite value More... | |
Protected Attributes | |
base_type | val |
value | |
Static Protected Attributes | |
static const base_type | min_finity |
minimum finite value More... | |
static const base_type | max_finity |
maximum finite value More... | |
static const base_type | min_normal_neg_infty |
minimum normal infinite value More... | |
static const base_type | max_normal_pos_infty |
maximum normal infinite value More... | |
Friends | |
class | InftyInt |
bool | operator== (const TaintedInftyInt &x, const TaintedInftyInt &y) |
Equality test. More... | |
TaintedInftyInt | operator+ (const TaintedInftyInt &x, const FiniteInt &y) |
Add. More... | |
TaintedInftyInt | operator- (const TaintedInftyInt &x, const FiniteInt &y) |
Subtract. More... | |
TaintedInftyInt | operator+ (const InftyInt &x, const InftyInt &y) |
Add. More... | |
TaintedInftyInt | operator- (const InftyInt &x, const InftyInt &y) |
Subtract. More... | |
TaintedInftyInt | min (const TaintedInftyInt &x, const TaintedInftyInt &y) |
Minimum. More... | |
TaintedInftyInt | max (const TaintedInftyInt &x, const TaintedInftyInt &y) |
Maximum. More... | |
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.
|
inlineexplicit |
Construct from base type.
x | base type value |
|
inline |
Convert finite value to base type.
|
inline |
Test for finite
|
inline |
Test for negative infinity
|
inline |
Test for finite or normal infinity
|
inline |
Test for positive infinity
|
inlinestatic |
maximum finite value
|
inlinestatic |
minimum finite value
|
inline |
Assignment.
x | finite int to be assigned |
|
friend |
Maximum.
x | operand 1 |
y | operand 2 |
|
friend |
Minimum.
x | operand 1 |
y | operand 2 |
|
friend |
Add.
x | operand 1 |
y | operand 2 |
|
friend |
Add.
x | operand 1 |
y | operand 2 |
|
friend |
Subtract.
x | operand 1 |
y | operand 2 |
|
friend |
Subtract.
x | operand 1 |
y | operand 2 |
|
friend |
Less than operator
x | operand 1 |
y | operand 2 |
|
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 |
|
friend |
Less or equal than operator
x | operand 1 |
y | operand 2 |
|
friend |
Equality test.
x | operand 1 (tainted) |
y | operand 2 (tainted) |
|
friend |
Greater than operator
x | operand 1 |
y | operand 2 |
|
friend |
Greater or equal than operator
x | operand 1 |
y | operand 2 |
|
staticprotected |
maximum finite value
|
staticprotected |
maximum normal infinite value
|
staticprotected |
minimum finite value
|
staticprotected |
minimum normal infinite value