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 floatfloatValueprivate shortshortBitsstatic intSIZE
-
Constructor Summary
Constructors Constructor Description Half(short shortBits)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Half other)doubledoubleValue()booleanequals(java.lang.Object other)private static intfloatTo16Bits(float floatValue)static shortfloatToShortBits(float floatValue)Converts a float value to IEEE 754 half-precision bits.floatfloatValue()inthashCode()intintValue()longlongValue()static shortparseHalf(java.lang.String value)private java.lang.ObjectreadResolve()static floatshortBitsToFloat(short shortBits)Converts an IEEE 754 half-precision data type to single-precision.java.lang.StringtoString()static HalfvalueOf(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:
intValuein classjava.lang.Number
-
longValue
public long longValue()
- Specified by:
longValuein classjava.lang.Number
-
floatValue
public float floatValue()
- Specified by:
floatValuein classjava.lang.Number
-
doubleValue
public double doubleValue()
- Specified by:
doubleValuein classjava.lang.Number
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
compareTo
public int compareTo(Half other)
- Specified by:
compareToin interfacejava.lang.Comparable<Half>
-
toString
public java.lang.String toString()
- Overrides:
toStringin 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()
-
-