Class Half
- java.lang.Object
-
- java.lang.Number
-
- com.twelvemonkeys.imageio.metadata.tiff.Half
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<Half>
public final class Half extends java.lang.Number implements java.lang.Comparable<Half>
IEEE 754 half-precision floating point data type.- Version:
- $Id: Half.java,v 1.0 10/04/2021 haraldk Exp$
- See Also:
- Stack Overflow answer by x4u, Wikipedia, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private float
floatValue
private short
shortBits
static int
SIZE
-
Constructor Summary
Constructors Constructor Description Half(short shortBits)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Half other)
double
doubleValue()
boolean
equals(java.lang.Object other)
private static int
floatTo16Bits(float floatValue)
static short
floatToShortBits(float floatValue)
Converts a float value to IEEE 754 half-precision bits.float
floatValue()
int
hashCode()
int
intValue()
long
longValue()
static short
parseHalf(java.lang.String value)
private java.lang.Object
readResolve()
static float
shortBitsToFloat(short shortBits)
Converts an IEEE 754 half-precision data type to single-precision.java.lang.String
toString()
static Half
valueOf(java.lang.String value)
-
-
-
Field Detail
-
SIZE
public static final int SIZE
- See Also:
- Constant Field Values
-
shortBits
private final short shortBits
-
floatValue
private final transient float floatValue
-
-
Method Detail
-
intValue
public int intValue()
- Specified by:
intValue
in classjava.lang.Number
-
longValue
public long longValue()
- Specified by:
longValue
in classjava.lang.Number
-
floatValue
public float floatValue()
- Specified by:
floatValue
in classjava.lang.Number
-
doubleValue
public double doubleValue()
- Specified by:
doubleValue
in classjava.lang.Number
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
compareTo
public int compareTo(Half other)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Half>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
valueOf
public static Half valueOf(java.lang.String value) throws java.lang.NumberFormatException
- Throws:
java.lang.NumberFormatException
-
parseHalf
public static short parseHalf(java.lang.String value) throws java.lang.NumberFormatException
- Throws:
java.lang.NumberFormatException
-
shortBitsToFloat
public static float shortBitsToFloat(short shortBits)
Converts an IEEE 754 half-precision data type to single-precision.- Parameters:
shortBits
- a 16 bit half precision value- Returns:
- an IEE 754 single precision float
-
floatToShortBits
public static short floatToShortBits(float floatValue)
Converts a float value to IEEE 754 half-precision bits.- Parameters:
floatValue
- a float value- Returns:
- the IEE 754 single precision 16 bits value
-
floatTo16Bits
private static int floatTo16Bits(float floatValue)
-
readResolve
private java.lang.Object readResolve()
-
-