Half

value class Half(val v: UShort) : Comparable<Half>

A 16-bit half-precision floating-point number conforming to IEEE 754-2008.

Layout: 1 sign bit, 5 exponent bits, 10 mantissa bits.

+-+------+------------+
|s|eeeee |mmmmmmmmmm |
+-+------+------------+
  • Minimum (denormal) value: 2⁻²⁴ ≈ 5.96e-8

  • Minimum (normal) value: 2⁻¹⁴ ≈ 6.10e-5

  • Maximum value: (2 − 2⁻¹⁰) × 2¹⁵ = 65504

  • Integers in 0, 2048 are represented exactly.

Constructors

Link copied to clipboard
constructor(v: UShort)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The absolute value of this Half.

Link copied to clipboard

The unbiased exponent in the range MIN_EXPONENT, MAX_EXPONENT.

Link copied to clipboard
val sign: Half

Returns the sign of this value: NaN if this is NaN, +0 if zero, +1.0 or −1.0 otherwise.

Link copied to clipboard

The mantissa (significand) bits, in the range 0, 1023.

Link copied to clipboard
val ulp: Half

The unit in the last place (ULP) of this value.

Link copied to clipboard
val v: UShort

the raw 16-bit representation

Functions

Link copied to clipboard
open operator override fun compareTo(other: Half): Int
Link copied to clipboard
operator fun dec(): Half
Link copied to clipboard
operator fun div(other: Half): Half
Link copied to clipboard
inline operator fun Half.div(v: Half3): Half3
inline operator fun Half.div(v: Half4): Half4
Link copied to clipboard
operator fun inc(): Half
Link copied to clipboard

Returns true if this value is finite (not NaN, not infinite).

Link copied to clipboard

Returns true if this value is positive or negative infinity.

Link copied to clipboard
fun isNaN(): Boolean

Returns true if this value is NaN.

Link copied to clipboard

Returns true if this value is a normalized (non-denormal, non-zero, finite) number.

Link copied to clipboard

Returns true if this value is positive or negative zero.

Link copied to clipboard
operator fun minus(other: Half): Half
Link copied to clipboard
inline operator fun Half.minus(v: Half3): Half3
inline operator fun Half.minus(v: Half4): Half4
Link copied to clipboard
fun nextDown(): Half

Returns the largest Half value that is less than this value.

Link copied to clipboard

Returns the adjacent Half value in the direction of to.

Link copied to clipboard
fun nextUp(): Half

Returns the smallest Half value that is greater than this value.

Link copied to clipboard
operator fun plus(other: Half): Half
Link copied to clipboard
inline operator fun Half.plus(v: Half3): Half3
inline operator fun Half.plus(v: Half4): Half4
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
operator fun times(other: Half): Half
Link copied to clipboard
inline operator fun Half.times(v: Half3): Half3
inline operator fun Half.times(v: Half4): Half4
Link copied to clipboard
fun toBits(): Int

Returns the raw 16-bit representation as an Int.

Link copied to clipboard
fun toByte(): Byte

Converts this Half to a Byte by truncation via Float.

Link copied to clipboard

Converts this Half to a Double.

Link copied to clipboard
fun toFloat(): Float

Converts this Half to a Float.

Link copied to clipboard
Link copied to clipboard
fun toInt(): Int

Converts this Half to an Int by truncation via Float.

Link copied to clipboard
fun toLong(): Long

Converts this Half to a Long by truncation via Float.

Link copied to clipboard
fun toShort(): Short

Converts this Half to a Short by truncation via Float.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
operator fun unaryMinus(): Half
Link copied to clipboard
operator fun unaryPlus(): Half
Link copied to clipboard
fun withSign(sign: Half): Half

Returns this value with the sign of sign.