public class ReinterpretUtils extends Object
| Constructor and Description |
|---|
ReinterpretUtils() |
| Modifier and Type | Method and Description |
|---|---|
static IntegerStamp |
floatToInt(FloatStamp stamp)
Compute the
IntegerStamp from a FloatStamp, losing as little information as
possible. |
static Constant |
foldConstant(Stamp resultStamp,
Constant constant)
Reinterpret the constant as a constant matching the given stamp.
|
static FloatStamp |
intToFloat(IntegerStamp stamp)
Compute the
IntegerStamp from a FloatStamp, losing as little information as
possible. |
public static Constant foldConstant(Stamp resultStamp, Constant constant)
public static IntegerStamp floatToInt(FloatStamp stamp)
IntegerStamp from a FloatStamp, losing as little information as
possible.
Sorting by their bit pattern reinterpreted as signed integers gives the following order of
floating point numbers:
-0 | negative numbers | -Inf | NaNs | 0 | positive numbers | +Inf | NaNs
So we can compute a better integer range if we know that the input is positive, negative,
finite, non-zero and/or not NaN.public static FloatStamp intToFloat(IntegerStamp stamp)
IntegerStamp from a FloatStamp, losing as little information as
possible.
Sorting by their bit pattern reinterpreted as signed integers gives the following order of
floating point numbers:
-0 | negative numbers | -Inf | NaNs | 0 | positive numbers | +Inf | NaNs
So from certain integer ranges we may be able to infer something about the sign, finiteness
or NaN-ness of the result.