Class/Object

org.emergentorder.onnx

Float16

Related Docs: object Float16 | package onnx

Permalink

final class Float16 extends AnyVal

Float16 represents 16-bit floating-point values.

This type does not actually support arithmetic directly. The expected use case is to convert to Float to perform any actual arithmetic, then convert back to a Float16 if needed.

Binary representation:

sign (1 bit) | | exponent (5 bits) | | | | mantissa (10 bits) | | | x xxxxx xxxxxxxxxx

Value interpretation (in order of precedence, with _ wild):

0 00000 0000000000 (positive) zero 1 00000 0000000000 negative zero _ 00000 subnormal number _ 11111 0000000000 +/- infinity _ 11111 not-a-number _ _ normal number

For non-zero exponents, the mantissa has an implied leading 1 bit, so 10 bits of data provide 11 bits of precision for normal numbers.

Self Type
Float16
Linear Supertypes
AnyVal, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Float16
  2. AnyVal
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Float16(raw: Short)

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    Any
  3. def *(rhs: Float16): Float16

    Permalink
  4. def **(rhs: Int): Float16

    Permalink
  5. def +(rhs: Float16): Float16

    Permalink
  6. def -(rhs: Float16): Float16

    Permalink
  7. def /(rhs: Float16): Float16

    Permalink
  8. def <(rhs: Float16): Boolean

    Permalink
  9. def <=(rhs: Float16): Boolean

    Permalink
  10. def ==(rhs: Float16): Boolean

    Permalink
  11. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    Any
  12. def >(rhs: Float16): Boolean

    Permalink
  13. def >=(rhs: Float16): Boolean

    Permalink
  14. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  15. def getClass(): Class[_ <: AnyVal]

    Permalink
    Definition Classes
    AnyVal → Any
  16. def isFinite: Boolean

    Permalink

    Whether this Float16 value is finite or not.

    Whether this Float16 value is finite or not.

    For the purposes of this method, infinities and NaNs are considered non-finite. For those values it returns false and for all other values it returns true.

  17. def isInfinite: Boolean

    Permalink
  18. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  19. def isNaN: Boolean

    Permalink
  20. def isNegativeInfinity: Boolean

    Permalink
  21. def isNegativeZero: Boolean

    Permalink
  22. def isPositiveInfinity: Boolean

    Permalink
  23. def isPositiveZero: Boolean

    Permalink
  24. def isZero: Boolean

    Permalink

    Returns if this is a zero value (positive or negative).

  25. def nonNaN: Boolean

    Permalink
  26. def nonZero: Boolean

    Permalink
  27. val raw: Short

    Permalink
  28. def signum: Float

    Permalink

    Return the sign of a Float16 value as a Float.

    Return the sign of a Float16 value as a Float.

    There are five possible return values:

    * NaN: the value is Float16.NaN (and has no sign) * -1F: the value is a non-zero negative number * -0F: the value is Float16.NegativeZero * 0F: the value is Float16.Zero * 1F: the value is a non-zero positive number

    PositiveInfinity and NegativeInfinity return their expected signs.

  29. def toFloat: Float

    Permalink

    Convert this Float16 value to the nearest Float.

    Convert this Float16 value to the nearest Float.

    Non-finite values and zero values will be mapped to the corresponding Float value.

    All other finite values will be handled depending on whether they are normal or subnormal. The relevant formulas are:

    * normal: (sign*2-1) * 2(exponent-15) * (1 + mantissa/1024) * subnormal: (sign*2-1) * 2-14 * (mantissa/1024)

    Given any (x: Float16), Float16.fromFloat(x.toFloat) = x

    The reverse is not necessarily true, since there are many Float values which are not precisely representable as Float16 values.

  30. def toString(): String

    Permalink

    String representation of this Float16 value.

    String representation of this Float16 value.

    Definition Classes
    Float16 → Any
  31. def unary_-: Float16

    Permalink

    Reverse the sign of this Float16 value.

    Reverse the sign of this Float16 value.

    This just involves toggling the sign bit with XOR.

    -Float16.NaN has no meaningful effect. -Float16.Zero returns Float16.NegativeZero.

Inherited from AnyVal

Inherited from Any

Ungrouped