public final class FpFormat
extends java.lang.Object
FpFormat
represents a floating-point number format.Modifier and Type | Field and Description |
---|---|
static FpFormat |
DOUBLE
The IEEE 754 double-precision format.
|
static FpFormat |
SINGLE
The IEEE 754 single-precision format.
|
Constructor and Description |
---|
FpFormat(int exponentLength,
int fractionLength)
Constructs a floating-point number format.
|
Modifier and Type | Method and Description |
---|---|
long |
getBits(long sign,
long exponent,
long fraction)
Returns the bit representation of the floating-point number.
|
long |
getExponent(long bits)
Returns the exponent of the given floating-point number.
|
long |
getExponentBias()
Returns the exponent bias.
|
int |
getExponentLength()
Returns the exponent length.
|
long |
getExponentMask()
Returns the exponent mask.
|
long |
getFraction(long bits)
Returns the fraction of the given floating-point number.
|
int |
getFractionLength()
Returns the fraction length.
|
long |
getFractionMask()
Returns the fraction mask.
|
int |
getLength()
Returns the bit length of a floating-point number.
|
long |
getMaxNormalizedExponent()
Returns the maximal exponent of a normalized floating-point number.
|
long |
getMinNormalizedExponent()
Returns the minimal exponent of a normalized floating-point number.
|
int |
getPrecision()
Returns the precision (the fraction length plus one).
|
long |
getSign(long bits)
Returns the sign of the given floating-point number.
|
int |
getSignLength()
Returns the sign length.
|
long |
getSignMask()
Returns the sign length.
|
FpNumber |
valueOf(long sign,
long exponent,
long fraction)
Constructs a floating-point number.
|
FpNumber |
valueOfBits(long bits)
Constructs a floating-point number.
|
FpNumber |
valueOfUnsigned(long value)
Constructs a floating-point number.
|
public static final FpFormat SINGLE
public static final FpFormat DOUBLE
public FpFormat(int exponentLength, int fractionLength)
exponentLength
- the exponent length.fractionLength
- the fraction length.public int getLength()
public int getFractionLength()
public int getExponentLength()
public int getSignLength()
public long getFractionMask()
public long getExponentMask()
public long getSignMask()
public int getPrecision()
public long getExponentBias()
public long getMinNormalizedExponent()
public long getMaxNormalizedExponent()
public long getFraction(long bits)
bits
- the bits representing the floating-point number.public long getExponent(long bits)
bits
- the bits representing the floating-point number.public long getSign(long bits)
bits
- the bits representing the floating-point number.public long getBits(long sign, long exponent, long fraction)
sign
- the sign.exponent
- the exponent.fraction
- the fraction.public FpNumber valueOf(long sign, long exponent, long fraction)
sign
- the sign.exponent
- the exponent.fraction
- the fraction.public FpNumber valueOfBits(long bits)
bits
- the bit representation.public FpNumber valueOfUnsigned(long value)
value
- the unsigned integer value.