Package com.io7m.ieee754b16
Class Binary32
java.lang.Object
com.io7m.ieee754b16.Binary32
Utility functions related to the binary32
format specified in
IEEE 754 2008
.
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
unpackGetExponentUnbiased
(float d) Extract and unbias the exponent of the given packedfloat
value.static int
unpackGetSign
(float d) Retrieve the sign bit of the given floating point value, as an integer.static int
unpackGetSignificand
(float d) Return the significand of the given floating point value as an integer.
-
Method Details
-
unpackGetExponentUnbiased
public static int unpackGetExponentUnbiased(float d) Extract and unbias the exponent of the given packed
float
value.The exponent is encoded biased as a number in the range
[0, 255]
, with0
indicating that the number is subnormal and[1, 254]
denoting the actual exponent plusBIAS
. Infinite andNaN
values always have a biased exponent of255
.This function will therefore return:
-
0 -
iff the input is a subnormal number.BIAS
= -127 - An integer in the range
[1 -
iff the input is a normal number.BIAS
, 254 -BIAS
] = [-126, 127] -
255 -
iff the input isBIAS
= 128Float.POSITIVE_INFINITY
,Float.NEGATIVE_INFINITY
, orNaN
.
- Parameters:
d
- A floating point value- Returns:
- An unbiased exponent
-
-
unpackGetSign
public static int unpackGetSign(float d) Retrieve the sign bit of the given floating point value, as an integer.- Parameters:
d
- A floating point value- Returns:
- An unpacked sign bit
-
unpackGetSignificand
public static int unpackGetSignificand(float d) Return the significand of the given floating point value as an integer.
- Parameters:
d
- A floating point value- Returns:
- An unpacked significand
- See Also:
-