Float16 is a class holding 16-bit data
in IEEE 754 binary16 format.
Binary16 Format:
S EEEEE MMMMMMMMMM
Sign - 1 bit
Exponent - 5 bits
Significand - 10 bits (does not include the implicit bit
inferred from the exponent, see PRECISION)
Unless otherwise specified, the methods in this class use a rounding policy (JLS 15.4) of round to nearest.
This is a value-based class; programmers should treat instances that are equal as interchangeable and should not use instances for synchronization, or unpredictable behavior may occur. For example, in a future release, synchronization may fail.
java.lang.Double has a discussion of equality,
equivalence, and comparison of floating-point values that is
equally applicable to Float16 values.
java.lang.Double is also
applicable to Float16 values.
API Note
The methods in this class generally have analogous methods in
either Float/Double or Math/StrictMath. Unless otherwise specified, the handling of special
floating-point values such as NaN
values, infinities, and signed
zeros of methods in this class is wholly analogous to the handling
of equivalent cases by methods in Float, Double,
Math, etc.
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private static class | |
| private static class | Float16.
This class exposes package private utilities for other classes. |
| Modifier and Type | Field and Description |
|---|---|
| public static final int | BYTES
The number of bytes used to represent a |
| public static final int | MAX_EXPONENT
Maximum exponent a finite |
| public static final Float16 | MAX_VALUE
A constant holding the largest positive finite value of type
|
| public static final int | MIN_EXPONENT
Minimum exponent a normalized |
| public static final Float16 | MIN_NORMAL
A constant holding the smallest positive normal value of type
|
| public static final Float16 | MIN_VALUE
A constant holding the smallest positive nonzero value of type
|
| public static final Float16 | NaN
A constant holding a Not-a-Number (NaN) value of type |
| public static final Float16 | NEGATIVE_INFINITY
A constant holding the negative infinity of type |
| private static final Float16 | ONE
A constant holding a one (1.0) of type |
| private static final double | OVERFLOW_THRESH
The overflow threshold (for round to nearest) is MAX_VALUE + 1/2 ulp. |
| public static final Float16 | POSITIVE_INFINITY
A constant holding the positive infinity of type |
| public static final int | PRECISION
The number of bits in the significand of a |
| private static final long | |
| public static final int | SIZE
The number of bits used to represent a |
| private static final double | UNDERFLOW_THRESH
The underflow threshold (for round to nearest) is MIN_VALUE * 0.5. |
| private final short | value
Primitive |
| private static final Float16 | ZERO
A constant holding a zero (0.0) of type |
| Access | Constructor and Description |
|---|---|
| private | Float16(short
a short value. bits)Returns a |
| Modifier and Type | Method and Description |
|---|---|
| public static Float16 | |
| public static Float16 | |
| public byte | Returns: the value of thisFloat16 as a byte after
a narrowing primitive conversionOverrides java. Returns the value of this |
| public static int | Returns: the value0 if f1 is
numerically equal to f2; a value less than
0 if f1 is numerically less than
f2; and a value greater than 0
if f1 is numerically greater than
f2.the first f1, Float16 Float16 to comparethe second f2)Float16 to compareCompares the two specified |
| public int | Returns: the value0 if anotherFloat16 is
numerically equal to this Float16; a value
less than 0 if this Float16
is numerically less than anotherFloat16;
and a value greater than 0 if this
Float16 is numerically greater than
anotherFloat16.the anotherFloat16)Float16 to be compared.Implements java. Compares two |
| public static Float16 | Returns: a value with the magnitude ofmagnitude
and the sign of sign.the parameter providing the magnitude of the result magnitude, Float16 the parameter providing the sign of the result sign)Returns the first floating-point argument with the sign of the second floating-point argument. |
| public static Float16 | |
| public double | Returns: the value of thisFloat16 as a double
after a widening primitive conversionImplements abstract java. Returns the value of this |
| public boolean | equals(Object obj)
Overrides java. Compares this object against the specified object. |
| private static int | |
| public static short | Returns: the bits that represent the floating-point number.a f16)Float16 floating-point number.Returns a representation of the specified floating-point value according to the IEEE 754 floating-point binary16 bit layout. |
| public static short | Returns: the bits that represent the floating-point number.a f16)Float16 floating-point number.Returns a representation of the specified floating-point value according to the IEEE 754 floating-point binary16 bit layout. |
| public float | Returns: the value of thisFloat16 as a float
after a widening primitive conversionImplements abstract java. Returns the value of this |
| public static Float16 | Returns: (a × b + c) computed, as if with unlimited range and precision, and rounded once to the nearestFloat16 valuea value a, Float16 a value b, Float16 a value c)Returns the fused multiply add of the three arguments; that is,
returns the exact product of the first two arguments summed
with the third argument and then rounded once to the nearest
|
| public static int | Returns: the unbiased exponent of the argumenta f16)Float16 valueReturns the unbiased exponent used in the representation of a
|
| pack-priv static int | getExponent0(short bits)
From the bitwise representation of a float16, mask out exponent bits, shift to the right and then subtract out float16's bias adjust, 15, to get true exponent value. |
| public int | Returns: a hash code for thisFloat16 objectOverrides java. Returns a hash code for this |
| public static int | |
| public int | Returns: the value of thisFloat16 as an int after
a narrowing primitive conversionImplements abstract java. Returns the value of this |
| public static boolean | |
| public static boolean | Returns: true if the argument is positive infinity or
negative infinity; false otherwise.the value to be tested. f16)Returns |
| public static boolean | |
| private static boolean | |
| public long | Returns: value of thisFloat16 as a long after a
narrowing primitive conversionImplements abstract java. Returns value of this |
| public static Float16 | |
| public static Float16 | |
| public static Float16 | |
| public static Float16 | |
| public static Float16 | |
| public static Float16 | |
| private static boolean | |
| public static Float16 | |
| public static Float16 | Returns: theFloat16 floating-point value with the same
bit pattern.any bits)short integer.Returns the |
| public short | Returns: the value of thisFloat16 as a short
after a narrowing primitive conversionOverrides java. Returns the value of this |
| public static Float16 | |
| public static Float16 | |
| public static Float16 | |
| public static String | Returns: a hex string representation of the argument.the f16)Float16 to be converted.Returns a hexadecimal string representation of the |
| public static String | |
| public String | Returns: a string representation of thisFloat16Overrides java. Returns a string representation of this |
| public static Float16 | |
| public static Float16 | Returns: the value of anint converted to Float16an value)int value.Returns the value of an |
| public static Float16 | Returns: the value of along converted to Float16a value)long value.Returns the value of a |
| public static Float16 | Returns: aFloat16 value rounded from the float
argument using the round to nearest rounding policya f)floatReturns a |
| public static Float16 | Returns: aFloat16 value rounded from the double
argument using the round to nearest rounding policya d)doubleReturns a |
| public static Float16 | |
| public static Float16 | Returns: aFloat16 value rounded from the BigDecimal
argument using the round to nearest rounding policyReturns a |