public class Quantizer
extends java.lang.Object
FixPoint
,
Overflow
,
Precision
,
Rounding
,
Quantization
Modifier and Type | Field and Description |
---|---|
static Overflow |
OVERFLOW_TO_ZERO
Indicate that overflow should result in a zero value.
|
static Overflow |
SATURATE
Indicate that overflow should saturate.
|
Modifier and Type | Method and Description |
---|---|
static FixPoint |
round(java.math.BigDecimal value,
Precision precision)
Return the fixed point number that is nearest to the specified
value, but has the given precision, possibly introducing
quantization or overflow errors.
|
static FixPoint |
round(double value,
Precision precision)
Return the fixed point number that is nearest to the specified
value, but has the given precision, possibly introducing
quantization or overflow errors.
|
static FixPoint |
round(FixPoint value,
Precision newPrecision,
Overflow mode)
Return the fixed point number that is nearest to the specified
value, but has the given precision, possibly introducing
quantization or overflow errors.
|
static FixPoint |
roundDown(java.math.BigDecimal value,
Precision precision)
Return the nearest fixed point number with less than or equal
magnitude that has the given precision, possibly introducing
quantization or overflow errors.
|
static FixPoint |
roundDown(double value,
Precision precision)
Return the nearest fixed point number with less than or equal
magnitude that has the given precision, possibly introducing
quantization or overflow errors.
|
static FixPoint |
roundDown(FixPoint value,
Precision newPrecision,
Overflow mode)
Return the nearest fixed point number with less than or equal
magnitude that has the given precision, possibly introducing
quantization or overflow errors.
|
static FixPoint |
roundNearestEven(java.math.BigDecimal value,
Precision precision)
Return the fixed point number that is nearest to the specified
value, but has the given precision, possibly introducing
quantization or overflow errors.
|
static FixPoint |
roundNearestEven(double value,
Precision precision)
Return the fixed point number that is nearest to the specified
value, but has the given precision, possibly introducing
quantization or overflow errors.
|
static FixPoint |
roundNearestEven(FixPoint value,
Precision newPrecision,
Overflow mode)
Return the fixed point number that is nearest to the specified
value, but has the given precision, possibly introducing
quantization or overflow errors.
|
static FixPoint |
roundToZero(java.math.BigDecimal value,
Precision precision)
Return the fixed point number that is nearest to the specified
value, but has magnitude no greater that the specified value,
and has the given precision, possibly introducing
quantization or overflow errors.
|
static FixPoint |
roundToZero(double value,
Precision precision)
Return the fixed point number that is nearest to the specified
value, but has magnitude no greater that the specified value,
and has the given precision, possibly introducing
quantization or overflow errors.
|
static FixPoint |
roundToZero(FixPoint value,
Precision newPrecision,
Overflow mode)
Return the fixed point number that is nearest to the specified
value, but has magnitude no greater than the specified value,
and has the given precision, possibly introducing
quantization or overflow errors.
|
static FixPoint |
roundUp(java.math.BigDecimal value,
Precision precision)
Return the smallest greater than or equal fixed point number
that has the given precision, possibly introducing
quantization or overflow errors.
|
static FixPoint |
roundUp(double value,
Precision precision)
Return the smallest greater than or equal fixed point number
that has the given precision, possibly introducing
quantization or overflow errors.
|
static FixPoint |
roundUp(FixPoint value,
Precision newPrecision,
Overflow mode)
Return the smallest greater than or equal fixed point number
that has the given precision, possibly introducing
quantization or overflow errors.
|
static FixPoint |
truncate(java.math.BigDecimal value,
Precision precision)
Deprecated.
Use roundToZero instead.
|
static FixPoint |
truncate(double value,
Precision precision)
Deprecated.
Use roundToZero instead.
|
static FixPoint |
truncate(FixPoint value,
Precision newPrecision,
Overflow mode)
Deprecated.
Use roundToZero instead.
|
public static final Overflow SATURATE
public static final Overflow OVERFLOW_TO_ZERO
public static FixPoint round(double value, Precision precision)
value
- The value to represent.precision
- The precision of the representation.public static FixPoint round(java.math.BigDecimal value, Precision precision)
value
- The value to represent.precision
- The precision of the representation.public static FixPoint round(FixPoint value, Precision newPrecision, Overflow mode)
value
- The value to represent.newPrecision
- The precision of the representation.mode
- The overflow mode.public static FixPoint roundDown(double value, Precision precision)
value
- The value to represent.precision
- The precision of the representation.public static FixPoint roundDown(java.math.BigDecimal value, Precision precision)
value
- The value to represent.precision
- The precision of the representation.public static FixPoint roundDown(FixPoint value, Precision newPrecision, Overflow mode)
value
- The value to represent.newPrecision
- The precision of the representation.mode
- The overflow mode.public static FixPoint roundNearestEven(double value, Precision precision)
value
- The value to represent.precision
- The precision of the representation.public static FixPoint roundNearestEven(java.math.BigDecimal value, Precision precision)
value
- The value to represent.precision
- The precision of the representation.public static FixPoint roundNearestEven(FixPoint value, Precision newPrecision, Overflow mode)
value
- The value to represent.newPrecision
- The precision of the representation.mode
- The overflow mode.public static FixPoint roundToZero(double value, Precision precision)
value
- The value to represent.precision
- The precision of the representation.public static FixPoint roundToZero(java.math.BigDecimal value, Precision precision)
value
- The value to represent.precision
- The precision of the representation.public static FixPoint roundToZero(FixPoint value, Precision newPrecision, Overflow mode)
value
- The value to represent.newPrecision
- The precision of the representation.mode
- The overflow mode.public static FixPoint roundUp(double value, Precision precision)
value
- The value to represent.precision
- The precision of the representation.public static FixPoint roundUp(java.math.BigDecimal value, Precision precision)
value
- The value to represent.precision
- The precision of the representation.public static FixPoint roundUp(FixPoint value, Precision newPrecision, Overflow mode)
value
- The value to represent.newPrecision
- The precision of the representation.mode
- The overflow mode.@Deprecated public static FixPoint truncate(double value, Precision precision)
Note: This method does NOT perform truncation per most fixed-point DSP implementations, which simply drop the fractional bits. Most models of fixed-point algorithms will use the roundDown methods in this class instead.
value
- The value to represent.precision
- The precision of the representation.@Deprecated public static FixPoint truncate(java.math.BigDecimal value, Precision precision)
Note: This method does NOT perform truncation per most fixed-point DSP implementations, which simply drop the fractional bits. Most models of fixed-point algorithms will use the roundDown methods in this class instead.
value
- The value to represent.precision
- The precision of the representation.@Deprecated public static FixPoint truncate(FixPoint value, Precision newPrecision, Overflow mode)
Note: This method does NOT perform truncation per most fixed-point DSP implementations, which simply drop the fractional bits. Most models of fixed-point algorithms will use the roundDown methods in this class instead.
value
- The value to represent.newPrecision
- The precision of the representation.mode
- The overflow mode.