| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_EXPONENT
The largest permitted exponent value, when using an exponent with offset.
|
static int |
MAX_EXPONENT_BITS
The largest permitted exponent value, when using raw exponent bits.
|
static int |
MAX_MANTISSA
The largest permitted mantissa value.
|
static int |
MIN_EXPONENT
The smallest permitted exponent value, when using an exponent with offset.
|
| Modifier and Type | Method and Description |
|---|---|
static int[] |
getAllParts(float f)
Returns an array containing the parts of the float.
|
static int[] |
getAllParts(float f,
boolean exponentAsBits)
Returns an array containing the parts of the float.
|
static int |
getExponent(float f)
Returns the exponent, after adding the exponent offset to the exponent bits.
|
static int |
getExponentBits(float f)
Returns the raw exponent bits, without adjusting for the offset.
|
static float |
getFloat(int sign,
int exponent,
int mantissa)
Creates a new float primitive using the provided component bits.
|
static float |
getFloat(int sign,
int exponent,
int mantissa,
boolean exponentAsBits)
Creates a new float primitive using the provided component bits.
|
static int |
getMantissa(float f)
Returns the mantissa bits (bits 51-0).
|
static int |
getSign(float f)
Returns the sign bit (bit 63).
|
static boolean |
isFinite(float f)
Returns true if f is finite--not infinite and not NaN.
|
static boolean |
isSubnormal(float f)
Returns whether or not this float is a subnormal value.
|
public static final int MAX_MANTISSA
public static final int MAX_EXPONENT_BITS
public static final int MIN_EXPONENT
public static final int MAX_EXPONENT
public static boolean isFinite(float f)
f - a float valuepublic static int getSign(float f)
f - a float valuepublic static int getExponent(float f)
getExponent(0.5) == -1 because 1.0 == 1.0 * 2^-1getExponent(1.0) == 0 because 1.0 == 1.0 * 2^0getExponent(2.0) == 1 because 2.0 == 1.0 * 2^1f - any float valuepublic static int getExponentBits(float f)
getExponentBits(0.5) == 0x3fegetExponentBits(1.0) == 0x3ffgetExponentBits(2.0) == 0x400f - a float valuepublic static int getMantissa(float f)
f - a float valuepublic static boolean isSubnormal(float f)
f - a float valuepublic static int[] getAllParts(float f)
f - a float valuepublic static int[] getAllParts(float f,
boolean exponentAsBits)
f - a float valueexponentAsBits - whether to return exponent as raw bits rather than adjusted valuepublic static float getFloat(int sign,
int exponent,
int mantissa)
sign - sign bitexponent - adjusted exponentmantissa - mantissa bitsIllegalArgumentException - if any of the parts contain invalid bits.public static float getFloat(int sign,
int exponent,
int mantissa,
boolean exponentAsBits)
sign - sign bitexponent - exponent (either raw bits or adjusted value)mantissa - mantissa bitsexponentAsBits - If true, assumes that exponent parameter represents the actual exponent bits. If false,
IEEE exponent offset value will be added to the offset to get the bits.IllegalArgumentException - if any of the parts contain invalid bits.