Float16
class Float16 : Comparable<Float16>
kotlin.Any  
↳  androidx.compose.ui.graphics.Float16 
Summary
Constants  

const Int 
Maximum exponent a finite halfprecision float may have. 
const Int 
Minimum exponent a normalized halfprecision float may have. 
const Int 
The number of bits used to represent a halfprecision float value. 
Public constructors  

Constructs a newly allocated 

Constructs a newly allocated 

Public methods  

Float16 
Returns the absolute value of the halfprecision float. 
Float16 
ceil() Returns the smallest halfprecision float value toward negative infinity greater than or equal to this halfprecision float value. 
operator Int 
Compares to another halfprecision float value. 
Float16 
floor() Returns the largest halfprecision float value toward positive infinity less than or equal to this halfprecision float value. 
Boolean 
isFinite() Returns false if the halfprecision float value represents infinity, true otherwise. 
Boolean 
Returns true if the halfprecision float value represents infinity, false otherwise. 
Boolean 
isNaN() Returns true if this 
Boolean 
Returns true if the halfprecision float value is normalized (does not have a subnormal representation). 
Float16 
round() Returns the closest integral halfprecision float value to the this halfprecision float value. 
Int 
toBits() Returns a representation of the halfprecision float value according to the bit layout described in Float16. 
Byte 
toByte() Returns the value of this 
Double 
toDouble() Returns the value of this 
Float 
toFloat() Returns the value of this 
String 
Returns a hexadecimal string representation of the halfprecision float value. 
Int 
toInt() Returns the value of this 
Long 
toLong() Returns the value of this 
Int 
Returns a representation of the halfprecision float value according to the bit layout described in Float16. 
Short 
toShort() Returns the value of this 
String 
toString() Returns a string representation of the specified halfprecision float value. 
Float16 
trunc() Returns the truncated halfprecision float value of this halfprecision float value. 
Float16 
Returns a Float16 with the magnitude of this and the sign of sign 
Inherited extension functions  

From androidx.core.util

Properties  

Int 
The unbiased exponent used in the representation of the specified halfprecision float value. 
Short  
Float16 
Returns the sign of this halfprecision float value. 
Int 
The significand, or mantissa, used in the representation of this halfprecision float value. 
Companion properties  

Float16 
Epsilon is the difference between 1. 
Float16 
Smallest negative value a halfprecision float may have. 
Float16 
Maximum positive finite value a halfprecision float may have. 
Float16 
Smallest positive normal value a halfprecision float may have. 
Float16 
Smallest positive nonzero value a halfprecision float may have. 
Float16 
A NotaNumber representation of a halfprecision float. 
Float16 
Negative infinity of type halfprecision float. 
Float16 
Negative 0 of type halfprecision float. 
Float16 
Positive infinity of type halfprecision float. 
Float16 
Positive 0 of type halfprecision float. 
Constants
MaxExponent
const val MaxExponent: Int
Maximum exponent a finite halfprecision float may have.
Value: 15
MinExponent
const val MinExponent: Int
Minimum exponent a normalized halfprecision float may have.
Value: 14
Size
const val Size: Int
The number of bits used to represent a halfprecision float value.
Value: 16
Public constructors
Float16
Float16(value: Float)
Constructs a newly allocated Float16
object that represents the
argument converted to a halfprecision float.
Parameters  

value: Float  The value to be represented by the Float16 
Float16
Float16(value: Double)
Constructs a newly allocated Float16
object that
represents the argument converted to a halfprecision float.
Parameters  

value: Double  The value to be represented by the Float16 
Float16
Float16(halfValue: Short)
Public methods
absoluteValue
fun absoluteValue(): Float16
Returns the absolute value of the halfprecision float. Special values are handled in the following ways:
 If the specified halfprecision float is NaN, the result is NaN
 If the specified halfprecision float is zero (negative or positive), the result is positive zero (see PositiveZero)
 If the specified halfprecision float is infinity (negative or positive), the result is positive infinity (see PositiveInfinity)
ceil
fun ceil(): Float16
Returns the smallest halfprecision float value toward negative infinity greater than or equal to this halfprecision float value. Special values are handled in the following ways:
 If the specified halfprecision float is NaN, the result is NaN
 If the specified halfprecision float is infinity (negative or positive), the result is infinity (with the same sign)
 If the specified halfprecision float is zero (negative or positive), the result is zero (with the same sign)
Return  

The smallest halfprecision float value toward negative infinity  greater than or equal to the halfprecision float value 
compareTo
operator fun compareTo(other: Float16): Int
Compares to another halfprecision float value. The following conditions apply during the comparison:
 NaN is considered by this method to be equal to itself and greater
than all other halfprecision float values (including
#PositiveInfinity
)  PositiveZero is considered by this method to be greater than NegativeZero.
Parameters  

other: Float16  The halfprecision float value to compare to the halfprecision value
represented by this Float16 object 
Return  

The value  0 if this is numerically equal to h ; a
value less than 0 if this is numerically less than h ;
and a value greater than 0 if this is numerically greater
than h 
floor
fun floor(): Float16
Returns the largest halfprecision float value toward positive infinity less than or equal to this halfprecision float value. Special values are handled in the following ways:
 If the specified halfprecision float is NaN, the result is NaN
 If the specified halfprecision float is infinity (negative or positive), the result is infinity (with the same sign)
 If the specified halfprecision float is zero (negative or positive), the result is zero (with the same sign)
Return  

The largest halfprecision float value toward positive infinity  less than or equal to the halfprecision float value 
isFinite
fun isFinite(): Boolean
Returns false if the halfprecision float value represents infinity, true otherwise.
Return  

False if the value is positive infinity or negative infinity,  true otherwise 
isInfinite
fun isInfinite(): Boolean
Returns true if the halfprecision float value represents infinity, false otherwise.
Return  

True if the value is positive infinity or negative infinity,  false otherwise 
isNaN
fun isNaN(): Boolean
Returns true if this Float16
value represents a NotaNumber,
false otherwise.
Return  

True if the value is a NaN,  false otherwise 
isNormalized
fun isNormalized(): Boolean
Returns true if the halfprecision float value is normalized (does not have a subnormal representation). If the specified value is PositiveInfinity, NegativeInfinity, PositiveZero, NegativeZero, NaN or any subnormal number, this method returns false.
Return  

True if the value is normalized,  false otherwise 
round
fun round(): Float16
Returns the closest integral halfprecision float value to the this halfprecision float value. Special values are handled in the following ways:
 If the specified halfprecision float is NaN, the result is NaN
 If the specified halfprecision float is infinity (negative or positive), the result is infinity (with the same sign)
 If the specified halfprecision float is zero (negative or positive), the result is zero (with the same sign)
Return  

The value of the specified halfprecision float rounded to the nearest  halfprecision float value 
toBits
fun toBits(): Int
Returns a representation of the halfprecision float value according to the bit layout described in Float16.
Unlike toRawBits, this method collapses all possible NotaNumber values to a single canonical NotaNumber value defined by NaN.
Return  

The bits that represent the halfprecision float value 
toByte
fun toByte(): Byte
Returns the value of this Float16
as a Byte
after
a narrowing primitive conversion.
Return  

The halfprecision float value represented by this object 
converted to type Byte 
toDouble
fun toDouble(): Double
Returns the value of this Float16
as a Double
after
a widening primitive conversion.
Return  

The halfprecision float value represented by this object 
converted to type Double 
toFloat
fun toFloat(): Float
Returns the value of this Float16
as a Float
after
a widening primitive conversion.
Return  

The halfprecision float value represented by this object 
converted to type Float 
toHexString
fun toHexString(): String
Returns a hexadecimal string representation of the halfprecision
float value. If the value is a NaN, the result is "NaN"
,
otherwise the result follows this format:
 If the sign is positive, no sign character appears in the result
 If the sign is negative, the first character is
''
 If the value is inifinity, the string is
"Infinity"
 If the value is 0, the string is
"0x0.0p0"
 If the value has a normalized representation, the exponent and
significand are represented in the string in two fields. The significand
starts with
"0x1."
followed by its lowercase hexadecimal representation. Trailing zeroes are removed unless all digits are 0, then a single zero is used. The significand representation is followed by the exponent, represented by"p"
, itself followed by a decimal string of the unbiased exponent  If the value has a subnormal representation, the significand starts
with
"0x0."
followed by its lowercase hexadecimal representation. Trailing zeroes are removed unless all digits are 0, then a single zero is used. The significand representation is followed by the exponent, represented by"p14"
Return  

A hexadecimal string representation of the specified value 
toInt
fun toInt(): Int
Returns the value of this Float16
as a Int
after
a narrowing primitive conversion.
Return  

The halfprecision float value represented by this object 
converted to type Int 
toLong
fun toLong(): Long
Returns the value of this Float16
as a Long
after
a narrowing primitive conversion.
Return  

The halfprecision float value represented by this object 
converted to type Long 
toRawBits
fun toRawBits(): Int
Returns a representation of the halfprecision float value according to the bit layout described in Float16.
Return  

The bits that represent the halfprecision float value 
toShort
fun toShort(): Short
Returns the value of this Float16
as a Short
after
a narrowing primitive conversion.
Return  

The halfprecision float value represented by this object 
converted to type Short 
toString
fun toString(): String
Returns a string representation of the specified halfprecision float value. See toString for more information.
Return  

A string representation of this  Float16 object 
trunc
fun trunc(): Float16
Returns the truncated halfprecision float value of this halfprecision float value. Special values are handled in the following ways:
 If the specified halfprecision float is NaN, the result is NaN
 If the specified halfprecision float is infinity (negative or positive), the result is infinity (with the same sign)
 If the specified halfprecision float is zero (negative or positive), the result is zero (with the same sign)
Return  

The truncated halfprecision float value of the  halfprecision float value 
withSign
fun withSign(sign: Float16): Float16
Returns a Float16 with the magnitude of this and the sign of sign
Properties
exponent
val exponent: Int
The unbiased exponent used in the representation of the specified halfprecision float value. if the value is NaN or infinite, this* method returns MaxExponent + 1. If the argument is 0 or a subnormal representation, this method returns MinExponent  1.
halfValue
val halfValue: Short
sign
val sign: Float16
Returns the sign of this halfprecision float value.
1.0
if the value is negative, zero if the value is zero,
1.0
if the value is positive
Special case:
NaN.sign
isNaN
significand
val significand: Int
The significand, or mantissa, used in the representation of this halfprecision float value.
Companion properties
Epsilon
val Epsilon: Float16
Epsilon is the difference between 1.0 and the next value representable by a halfprecision floatingpoint.