public class FixPointFunctions
extends java.lang.Object
fix(5.34, 10, 4)creates a fixed point number with a total of 10 bits, 4 of which are integer bits, representing the number 5.34.
fix([ -.040609, -.001628, .17853, .37665, .37665, .17853, -.001628, -.040609 ], 10, 2)creates a matrix where each entry has 10 bits, two of which are integer bits.
quantize(5.34, 10, 4)quantizes the number 5.34 to 10 bits of precision, 4 of which are integer bits.
quantize([ -.040609, -.001628, .17853, .37665, .37665, .17853, -.001628, -.040609 ], 10, 2)creates a new instance of DoubleMatrixToken containing the specified values with 10 bits of precision, two of which are integer bits.
Modifier and Type | Method and Description |
---|---|
static FixPoint |
fix(double value,
int numberOfBits,
int integerBits)
Create a FixPoint representing the specified double.
|
static FixPoint |
fix(int value,
int numberOfBits,
int integerBits)
Create a FixPoint representing the specified integer.
|
static double |
quantize(double value,
int numberOfBits,
int integerBits)
Create a double whose value is the quantized version of
the given double value.
|
public static FixPoint fix(int value, int numberOfBits, int integerBits)
fix(5, 10, 4)creates a fixed point representation of the integer 5 with 10 bits of precision, 4 of which are integer bits.
value
- The value to represent.numberOfBits
- The total number of bits.integerBits
- The number of bits used for the integer part.public static FixPoint fix(double value, int numberOfBits, int integerBits)
fix(5.34, 10, 4)creates a fixed point representation of the numer 5.34 with 10 bits of precision, 4 of which are integer bits.
value
- The value to represent.numberOfBits
- The total number of bits.integerBits
- The number of bits used for the integer part.public static double quantize(double value, int numberOfBits, int integerBits)
quantize(5.34, 10, 4)yields a double representing 5.34 quantized to 10 bits of precision, of which 4 bits are used for the integer part and 6 bits are used for the fractional part.
value
- The value to quantize.numberOfBits
- The total number of bits.integerBits
- The number of bits used for the integer part.