Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/util/Half#constants) \| [Ctors](https://developer.android.com/reference/android/util/Half#pubctors) \| [Methods](https://developer.android.com/reference/android/util/Half#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/util/Half#inhmethods)

# Half

*** ** * ** ***

` public final class Half `   
` ` ` extends https://developer.android.com/reference/java/lang/Number ` ` implements https://developer.android.com/reference/java/lang/Comparable<https://developer.android.com/reference/android/util/Half> `

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [java.lang.Number](https://developer.android.com/reference/java/lang/Number) ||
|   | ↳ | android.util.Half |

<br />

*** ** * ** ***

<br />

The `Half` class is a wrapper and a utility class to manipulate half-precision 16-bit [IEEE 754](https://en.wikipedia.org/wiki/Half-precision_floating-point_format) floating point data types (also called fp16 or binary16). A half-precision float can be created from or converted to single-precision floats, and is stored in a short data type. To distinguish short values holding half-precision floats from regular short values, it is recommended to use the `@HalfFloat` annotation.

The IEEE 754 standard specifies an fp16 as having the following format:

- Sign bit: 1 bit
- Exponent width: 5 bits
- Significand: 10 bits

The format is laid out as follows:

```
1   11111   1111111111
^   --^--   ---^---
sign  |          |_______ significand
      |
      -- exponent
```

Half-precision floating points can be useful to save memory and/or bandwidth at the expense of range and precision when compared to single-precision floating points (fp32).

To help you decide whether fp16 is the right storage type for you need, please refer to the table below that shows the available precision throughout the range of possible values. The *precision* column indicates the step size between two consecutive numbers in a specific part of the range.

| Range start | Precision |
|---|---|
| 0 | 1 ⁄ 16,777,216 |
| 1 ⁄ 16,384 | 1 ⁄ 16,777,216 |
| 1 ⁄ 8,192 | 1 ⁄ 8,388,608 |
| 1 ⁄ 4,096 | 1 ⁄ 4,194,304 |
| 1 ⁄ 2,048 | 1 ⁄ 2,097,152 |
| 1 ⁄ 1,024 | 1 ⁄ 1,048,576 |
| 1 ⁄ 512 | 1 ⁄ 524,288 |
| 1 ⁄ 256 | 1 ⁄ 262,144 |
| 1 ⁄ 128 | 1 ⁄ 131,072 |
| 1 ⁄ 64 | 1 ⁄ 65,536 |
| 1 ⁄ 32 | 1 ⁄ 32,768 |
| 1 ⁄ 16 | 1 ⁄ 16,384 |
| 1 ⁄ 8 | 1 ⁄ 8,192 |
| 1 ⁄ 4 | 1 ⁄ 4,096 |
| 1 ⁄ 2 | 1 ⁄ 2,048 |
| 1 | 1 ⁄ 1,024 |
| 2 | 1 ⁄ 512 |
| 4 | 1 ⁄ 256 |
| 8 | 1 ⁄ 128 |
| 16 | 1 ⁄ 64 |
| 32 | 1 ⁄ 32 |
| 64 | 1 ⁄ 16 |
| 128 | 1 ⁄ 8 |
| 256 | 1 ⁄ 4 |
| 512 | 1 ⁄ 2 |
| 1,024 | 1 |
| 2,048 | 2 |
| 4,096 | 4 |
| 8,192 | 8 |
| 16,384 | 16 |
| 32,768 | 32 |

This table shows that numbers higher than 1024 lose all fractional precision.

<br />

## Summary

| ### Constants ||
|---|---|
| `short` | `https://developer.android.com/reference/android/util/Half#EPSILON` Epsilon is the difference between 1.0 and the next value representable by a half-precision floating-point. |
| `short` | `https://developer.android.com/reference/android/util/Half#LOWEST_VALUE` Smallest negative value a half-precision float may have. |
| `int` | `https://developer.android.com/reference/android/util/Half#MAX_EXPONENT` Maximum exponent a finite half-precision float may have. |
| `short` | `https://developer.android.com/reference/android/util/Half#MAX_VALUE` Maximum positive finite value a half-precision float may have. |
| `int` | `https://developer.android.com/reference/android/util/Half#MIN_EXPONENT` Minimum exponent a normalized half-precision float may have. |
| `short` | `https://developer.android.com/reference/android/util/Half#MIN_NORMAL` Smallest positive normal value a half-precision float may have. |
| `short` | `https://developer.android.com/reference/android/util/Half#MIN_VALUE` Smallest positive non-zero value a half-precision float may have. |
| `short` | `https://developer.android.com/reference/android/util/Half#NEGATIVE_INFINITY` Negative infinity of type half-precision float. |
| `short` | `https://developer.android.com/reference/android/util/Half#NEGATIVE_ZERO` Negative 0 of type half-precision float. |
| `short` | `https://developer.android.com/reference/android/util/Half#NaN` A Not-a-Number representation of a half-precision float. |
| `short` | `https://developer.android.com/reference/android/util/Half#POSITIVE_INFINITY` Positive infinity of type half-precision float. |
| `short` | `https://developer.android.com/reference/android/util/Half#POSITIVE_ZERO` Positive 0 of type half-precision float. |
| `int` | `https://developer.android.com/reference/android/util/Half#SIZE` The number of bits used to represent a half-precision float value. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/util/Half#Half(double)(double value) ` Constructs a newly allocated `Half` object that represents the argument converted to a half-precision float. |
| ` https://developer.android.com/reference/android/util/Half#Half(float)(float value) ` Constructs a newly allocated `Half` object that represents the argument converted to a half-precision float. |
| ` https://developer.android.com/reference/android/util/Half#Half(java.lang.String)(https://developer.android.com/reference/java/lang/String value) ` <br /> Constructs a newly allocated `Half` object that represents the half-precision float value represented by the string. |
| ` https://developer.android.com/reference/android/util/Half#Half(short)(short value) ` Constructs a newly allocated `Half` object that represents the half-precision float type argument. |

| ### Public methods ||
|---|---|
| ` static short` | ` https://developer.android.com/reference/android/util/Half#abs(short)(short h) ` Returns the absolute value of the specified half-precision float. |
| ` byte` | ` https://developer.android.com/reference/android/util/Half#byteValue()() ` Returns the value of this `Half` as a `byte` after a narrowing primitive conversion. |
| ` static short` | ` https://developer.android.com/reference/android/util/Half#ceil(short)(short h) ` Returns the smallest half-precision float value toward negative infinity greater than or equal to the specified half-precision float value. |
| ` static int` | ` https://developer.android.com/reference/android/util/Half#compare(short,%20short)(short x, short y) ` <br /> Compares the two specified half-precision float values. |
| ` int` | ` https://developer.android.com/reference/android/util/Half#compareTo(android.util.Half)(https://developer.android.com/reference/android/util/Half h) ` <br /> Compares the two specified half-precision float values. |
| ` static short` | ` https://developer.android.com/reference/android/util/Half#copySign(short,%20short)(short magnitude, short sign) ` Returns the first parameter with the sign of the second parameter. |
| ` double` | ` https://developer.android.com/reference/android/util/Half#doubleValue()() ` Returns the value of this `Half` as a `double` after a widening primitive conversion. |
| ` static boolean` | ` https://developer.android.com/reference/android/util/Half#equals(short,%20short)(short x, short y) ` Returns true if the two half-precision float values are equal. |
| ` boolean` | ` https://developer.android.com/reference/android/util/Half#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object o) ` Compares this object against the specified object. |
| ` float` | ` https://developer.android.com/reference/android/util/Half#floatValue()() ` Returns the value of this `Half` as a `float` after a widening primitive conversion. |
| ` static short` | ` https://developer.android.com/reference/android/util/Half#floor(short)(short h) ` Returns the largest half-precision float value toward positive infinity less than or equal to the specified half-precision float value. |
| ` static int` | ` https://developer.android.com/reference/android/util/Half#getExponent(short)(short h) ` Returns the unbiased exponent used in the representation of the specified half-precision float value. |
| ` static int` | ` https://developer.android.com/reference/android/util/Half#getSign(short)(short h) ` Returns the sign of the specified half-precision float. |
| ` static int` | ` https://developer.android.com/reference/android/util/Half#getSignificand(short)(short h) ` Returns the significand, or mantissa, used in the representation of the specified half-precision float value. |
| ` static boolean` | ` https://developer.android.com/reference/android/util/Half#greater(short,%20short)(short x, short y) ` Returns true if the first half-precision float value is greater (larger toward positive infinity) than the second half-precision float value. |
| ` static boolean` | ` https://developer.android.com/reference/android/util/Half#greaterEquals(short,%20short)(short x, short y) ` Returns true if the first half-precision float value is greater (larger toward positive infinity) than or equal to the second half-precision float value. |
| ` static int` | ` https://developer.android.com/reference/android/util/Half#halfToIntBits(short)(short h) ` <br /> Returns a representation of the specified half-precision float value according to the bit layout described in `https://developer.android.com/reference/android/util/Half`. |
| ` static int` | ` https://developer.android.com/reference/android/util/Half#halfToRawIntBits(short)(short h) ` <br /> Returns a representation of the specified half-precision float value according to the bit layout described in `https://developer.android.com/reference/android/util/Half`. |
| ` static short` | ` https://developer.android.com/reference/android/util/Half#halfToShortBits(short)(short h) ` <br /> Returns a representation of the specified half-precision float value according to the bit layout described in `https://developer.android.com/reference/android/util/Half`. |
| ` short` | ` https://developer.android.com/reference/android/util/Half#halfValue()() ` Returns the half-precision value of this `Half` as a `short` containing the bit representation described in `https://developer.android.com/reference/android/util/Half`. |
| ` static int` | ` https://developer.android.com/reference/android/util/Half#hashCode(short)(short h) ` Returns a hash code for a half-precision float value. |
| ` int` | ` https://developer.android.com/reference/android/util/Half#hashCode()() ` Returns a hash code for this `Half` object. |
| ` static short` | ` https://developer.android.com/reference/android/util/Half#intBitsToHalf(int)(int bits) ` <br /> Returns the half-precision float value corresponding to a given bit representation. |
| ` int` | ` https://developer.android.com/reference/android/util/Half#intValue()() ` Returns the value of this `Half` as a `int` after a narrowing primitive conversion. |
| ` static boolean` | ` https://developer.android.com/reference/android/util/Half#isInfinite(short)(short h) ` Returns true if the specified half-precision float value represents infinity, false otherwise. |
| ` boolean` | ` https://developer.android.com/reference/android/util/Half#isNaN()() ` Returns true if this `Half` value represents a Not-a-Number, false otherwise. |
| ` static boolean` | ` https://developer.android.com/reference/android/util/Half#isNaN(short)(short h) ` Returns true if the specified half-precision float value represents a Not-a-Number, false otherwise. |
| ` static boolean` | ` https://developer.android.com/reference/android/util/Half#isNormalized(short)(short h) ` Returns true if the specified half-precision float value is normalized (does not have a subnormal representation). |
| ` static boolean` | ` https://developer.android.com/reference/android/util/Half#less(short,%20short)(short x, short y) ` Returns true if the first half-precision float value is less (smaller toward negative infinity) than the second half-precision float value. |
| ` static boolean` | ` https://developer.android.com/reference/android/util/Half#lessEquals(short,%20short)(short x, short y) ` Returns true if the first half-precision float value is less (smaller toward negative infinity) than or equal to the second half-precision float value. |
| ` long` | ` https://developer.android.com/reference/android/util/Half#longValue()() ` Returns the value of this `Half` as a `long` after a narrowing primitive conversion. |
| ` static short` | ` https://developer.android.com/reference/android/util/Half#max(short,%20short)(short x, short y) ` Returns the larger of two half-precision float values (the value closest to positive infinity). |
| ` static short` | ` https://developer.android.com/reference/android/util/Half#min(short,%20short)(short x, short y) ` Returns the smaller of two half-precision float values (the value closest to negative infinity). |
| ` static short` | ` https://developer.android.com/reference/android/util/Half#parseHalf(java.lang.String)(https://developer.android.com/reference/java/lang/String s) ` Returns the half-precision float value represented by the specified string. |
| ` static short` | ` https://developer.android.com/reference/android/util/Half#round(short)(short h) ` Returns the closest integral half-precision float value to the specified half-precision float value. |
| ` short` | ` https://developer.android.com/reference/android/util/Half#shortValue()() ` Returns the value of this `Half` as a `short` after a narrowing primitive conversion. |
| ` static float` | ` https://developer.android.com/reference/android/util/Half#toFloat(short)(short h) ` <br /> Converts the specified half-precision float value into a single-precision float value. |
| ` static short` | ` https://developer.android.com/reference/android/util/Half#toHalf(float)(float f) ` <br /> Converts the specified single-precision float value into a half-precision float value. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/util/Half#toHexString(short)(short h) ` <br /> Returns a hexadecimal string representation of the specified half-precision float value. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/util/Half#toString(short)(short h) ` Returns a string representation of the specified half-precision float value. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/util/Half#toString()() ` Returns a string representation of the specified half-precision float value. |
| ` static short` | ` https://developer.android.com/reference/android/util/Half#trunc(short)(short h) ` Returns the truncated half-precision float value of the specified half-precision float value. |
| ` static https://developer.android.com/reference/android/util/Half` | ` https://developer.android.com/reference/android/util/Half#valueOf(java.lang.String)(https://developer.android.com/reference/java/lang/String s) ` Returns a `Half` instance representing the specified string value. |
| ` static https://developer.android.com/reference/android/util/Half` | ` https://developer.android.com/reference/android/util/Half#valueOf(float)(float f) ` Returns a `Half` instance representing the specified float value. |
| ` static https://developer.android.com/reference/android/util/Half` | ` https://developer.android.com/reference/android/util/Half#valueOf(short)(short h) ` Returns a `Half` instance representing the specified half-precision float value. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Number ` ` byte` ` https://developer.android.com/reference/java/lang/Number#byteValue()() `

Returns the value of the specified number as a `byte`.
` abstract double` ` https://developer.android.com/reference/java/lang/Number#doubleValue()() `

Returns the value of the specified number as a `double`.
` abstract float` ` https://developer.android.com/reference/java/lang/Number#floatValue()() `

Returns the value of the specified number as a `float`.
` abstract int` ` https://developer.android.com/reference/java/lang/Number#intValue()() `

Returns the value of the specified number as an `int`.
` abstract long` ` https://developer.android.com/reference/java/lang/Number#longValue()() `

Returns the value of the specified number as a `long`.
` short` ` https://developer.android.com/reference/java/lang/Number#shortValue()() `

Returns the value of the specified number as a `short`.
From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.
From interface ` https://developer.android.com/reference/java/lang/Comparable ` ` abstract int` ` https://developer.android.com/reference/java/lang/Comparable#compareTo(T)(https://developer.android.com/reference/android/util/Half o) `

Compares this object with the specified object for order.

## Constants

### EPSILON

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short EPSILON
```

Epsilon is the difference between 1.0 and the next value representable by a half-precision floating-point.

<br />

Constant Value: 5120 (0x00001400)

### LOWEST_VALUE

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short LOWEST_VALUE
```

Smallest negative value a half-precision float may have.

<br />

Constant Value: -1025 (0xfffffbff)

### MAX_EXPONENT

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int MAX_EXPONENT
```

Maximum exponent a finite half-precision float may have.

<br />

Constant Value: 15 (0x0000000f)

### MAX_VALUE

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short MAX_VALUE
```

Maximum positive finite value a half-precision float may have.

<br />

Constant Value: 31743 (0x00007bff)

### MIN_EXPONENT

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int MIN_EXPONENT
```

Minimum exponent a normalized half-precision float may have.

<br />

Constant Value: -14 (0xfffffff2)

### MIN_NORMAL

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short MIN_NORMAL
```

Smallest positive normal value a half-precision float may have.

<br />

Constant Value: 1024 (0x00000400)

### MIN_VALUE

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short MIN_VALUE
```

Smallest positive non-zero value a half-precision float may have.

<br />

Constant Value: 1 (0x00000001)

### NEGATIVE_INFINITY

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short NEGATIVE_INFINITY
```

Negative infinity of type half-precision float.

<br />

Constant Value: -1024 (0xfffffc00)

### NEGATIVE_ZERO

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short NEGATIVE_ZERO
```

Negative 0 of type half-precision float.

<br />

Constant Value: -32768 (0xffff8000)

### NaN

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short NaN
```

A Not-a-Number representation of a half-precision float.

<br />

Constant Value: 32256 (0x00007e00)

### POSITIVE_INFINITY

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short POSITIVE_INFINITY
```

Positive infinity of type half-precision float.

<br />

Constant Value: 31744 (0x00007c00)

### POSITIVE_ZERO

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final short POSITIVE_ZERO
```

Positive 0 of type half-precision float.

<br />

Constant Value: 0 (0x00000000)

### SIZE

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SIZE
```

The number of bits used to represent a half-precision float value.

<br />

Constant Value: 16 (0x00000010)

## Public constructors

### Half

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Half (double value)
```

Constructs a newly allocated `Half` object that represents the argument converted to a half-precision float.

<br />

| Parameters ||
|---|---|
| `value` | `double`: The value to be represented by the `Half` <br /> |

**See also:**

- `https://developer.android.com/reference/android/util/Half#toHalf(float)`

### Half

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Half (float value)
```

Constructs a newly allocated `Half` object that represents the argument converted to a half-precision float.

<br />

| Parameters ||
|---|---|
| `value` | `float`: The value to be represented by the `Half` <br /> |

**See also:**

- `https://developer.android.com/reference/android/util/Half#toHalf(float)`

### Half

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Half (String value)
```

<br />

Constructs a newly allocated `Half` object that represents the half-precision float value represented by the string. The string is converted to a half-precision float value as if by the `https://developer.android.com/reference/android/util/Half#valueOf(java.lang.String)` method.

Calling this constructor is equivalent to calling:

```
    new Half(Float.parseFloat(value))
```

<br />

<br />

| Parameters ||
|---|---|
| `value` | `String`: A string to be converted to a `Half` This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NumberFormatException` | if the string does not contain a parsable number |

**See also:**

- `https://developer.android.com/reference/java/lang/Float#valueOf(java.lang.String)`
- `https://developer.android.com/reference/android/util/Half#toHalf(float)`

### Half

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Half (short value)
```

Constructs a newly allocated `Half` object that represents the half-precision float type argument.

<br />

| Parameters ||
|---|---|
| `value` | `short`: The value to be represented by the `Half` <br /> |

## Public methods

### abs

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static short abs (short h)
```

Returns the absolute value of the specified half-precision float. Special values are handled in the following ways:

- If the specified half-precision float is NaN, the result is NaN
- If the specified half-precision float is zero (negative or positive), the result is positive zero (see `https://developer.android.com/reference/android/util/Half#POSITIVE_ZERO`)
- If the specified half-precision float is infinity (negative or positive), the result is positive infinity (see `https://developer.android.com/reference/android/util/Half#POSITIVE_INFINITY`)

<br />

<br />

| Parameters ||
|---|---|
| `h` | `short`: A half-precision float value <br /> |

| Returns ||
|---|---|
| `short` | The absolute value of the specified half-precision float <br /> |

### byteValue

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public byte byteValue ()
```

Returns the value of this `Half` as a `byte` after a narrowing primitive conversion.

<br />

| Returns ||
|---|---|
| `byte` | The half-precision float value represented by this object converted to type `byte` <br /> |

### ceil

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static short ceil (short h)
```

Returns the smallest half-precision float value toward negative infinity greater than or equal to the specified half-precision float value. Special values are handled in the following ways:

- If the specified half-precision float is NaN, the result is NaN
- If the specified half-precision float is infinity (negative or positive), the result is infinity (with the same sign)
- If the specified half-precision float is zero (negative or positive), the result is zero (with the same sign)

<br />

<br />

| Parameters ||
|---|---|
| `h` | `short`: A half-precision float value <br /> |

| Returns ||
|---|---|
| `short` | The smallest half-precision float value toward negative infinity greater than or equal to the specified half-precision float value <br /> |

### compare

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int compare (short x, 
                short y)
```

<br />

Compares the two specified half-precision float values. The following conditions apply during the comparison:

- `https://developer.android.com/reference/android/util/Half#NaN` is considered by this method to be equal to itself and greater than all other half-precision float values (including `#POSITIVE_INFINITY`)
- `https://developer.android.com/reference/android/util/Half#POSITIVE_ZERO` is considered by this method to be greater than `https://developer.android.com/reference/android/util/Half#NEGATIVE_ZERO`.

<br />

<br />

| Parameters ||
|---|---|
| `x` | `short`: The first half-precision float value to compare. <br /> |
| `y` | `short`: The second half-precision float value to compare <br /> |

| Returns ||
|---|---|
| `int` | The value `0` if `x` is numerically equal to `y`, a value less than `0` if `x` is numerically less than `y`, and a value greater than `0` if `x` is numerically greater than `y` <br /> |

### compareTo

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int compareTo (Half h)
```

<br />

Compares the two specified half-precision float values. The following conditions apply during the comparison:

- `https://developer.android.com/reference/android/util/Half#NaN` is considered by this method to be equal to itself and greater than all other half-precision float values (including `#POSITIVE_INFINITY`)
- `https://developer.android.com/reference/android/util/Half#POSITIVE_ZERO` is considered by this method to be greater than `https://developer.android.com/reference/android/util/Half#NEGATIVE_ZERO`.

<br />

<br />

| Parameters ||
|---|---|
| `h` | `Half`: The half-precision float value to compare to the half-precision value represented by this `Half` object. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `int` | The value `0` if `x` is numerically equal to `y`; a value less than `0` if `x` is numerically less than `y`; and a value greater than `0` if `x` is numerically greater than `y` <br /> |

### copySign

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static short copySign (short magnitude, 
                short sign)
```

Returns the first parameter with the sign of the second parameter. This method treats NaNs as having a sign.

<br />

| Parameters ||
|---|---|
| `magnitude` | `short`: A half-precision float value providing the magnitude of the result <br /> |
| `sign` | `short`: A half-precision float value providing the sign of the result <br /> |

| Returns ||
|---|---|
| `short` | A value with the magnitude of the first parameter and the sign of the second parameter <br /> |

### doubleValue

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public double doubleValue ()
```

Returns the value of this `Half` as a `double` after a widening primitive conversion.

<br />

| Returns ||
|---|---|
| `double` | The half-precision float value represented by this object converted to type `double` <br /> |

### equals

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean equals (short x, 
                short y)
```

Returns true if the two half-precision float values are equal. If either of the values is NaN, the result is false. `https://developer.android.com/reference/android/util/Half#POSITIVE_ZERO` and `https://developer.android.com/reference/android/util/Half#NEGATIVE_ZERO` are considered equal.

<br />

| Parameters ||
|---|---|
| `x` | `short`: The first half-precision value <br /> |
| `y` | `short`: The second half-precision value <br /> |

| Returns ||
|---|---|
| `boolean` | True if x is equal to y, false otherwise <br /> |

### equals

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean equals (Object o)
```

Compares this object against the specified object. The result is `true` if and only if the argument is not `null` and is a `Half` object that represents the same half-precision value as the this object. Two half-precision values are considered to be the same if and only if the method `https://developer.android.com/reference/android/util/Half#halfToIntBits(short)` returns an identical `int` value for both.

<br />

| Parameters ||
|---|---|
| `o` | `Object`: The object to compare. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | True if the objects are the same, false otherwise <br /> |

**See also:**

- `https://developer.android.com/reference/android/util/Half#halfToIntBits(short)`

### floatValue

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public float floatValue ()
```

Returns the value of this `Half` as a `float` after a widening primitive conversion.

<br />

| Returns ||
|---|---|
| `float` | The half-precision float value represented by this object converted to type `float` <br /> |

### floor

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static short floor (short h)
```

Returns the largest half-precision float value toward positive infinity less than or equal to the specified half-precision float value. Special values are handled in the following ways:

- If the specified half-precision float is NaN, the result is NaN
- If the specified half-precision float is infinity (negative or positive), the result is infinity (with the same sign)
- If the specified half-precision float is zero (negative or positive), the result is zero (with the same sign)

<br />

<br />

| Parameters ||
|---|---|
| `h` | `short`: A half-precision float value <br /> |

| Returns ||
|---|---|
| `short` | The largest half-precision float value toward positive infinity less than or equal to the specified half-precision float value <br /> |

### getExponent

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getExponent (short h)
```

Returns the unbiased exponent used in the representation of the specified half-precision float value. if the value is NaN or infinite, this\* method returns `https://developer.android.com/reference/android/util/Half#MAX_EXPONENT` + 1. If the argument is 0 or a subnormal representation, this method returns `https://developer.android.com/reference/android/util/Half#MIN_EXPONENT` - 1.

<br />

| Parameters ||
|---|---|
| `h` | `short`: A half-precision float value <br /> |

| Returns ||
|---|---|
| `int` | The unbiased exponent of the specified value <br /> |

### getSign

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getSign (short h)
```

Returns the sign of the specified half-precision float.

<br />

| Parameters ||
|---|---|
| `h` | `short`: A half-precision float value <br /> |

| Returns ||
|---|---|
| `int` | 1 if the value is positive, -1 if the value is negative <br /> |

### getSignificand

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getSignificand (short h)
```

Returns the significand, or mantissa, used in the representation of the specified half-precision float value.

<br />

| Parameters ||
|---|---|
| `h` | `short`: A half-precision float value <br /> |

| Returns ||
|---|---|
| `int` | The significand, or significand, of the specified vlaue <br /> |

### greater

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean greater (short x, 
                short y)
```

Returns true if the first half-precision float value is greater (larger toward positive infinity) than the second half-precision float value. If either of the values is NaN, the result is false.

<br />

| Parameters ||
|---|---|
| `x` | `short`: The first half-precision value <br /> |
| `y` | `short`: The second half-precision value <br /> |

| Returns ||
|---|---|
| `boolean` | True if x is greater than y, false otherwise <br /> |

### greaterEquals

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean greaterEquals (short x, 
                short y)
```

Returns true if the first half-precision float value is greater (larger toward positive infinity) than or equal to the second half-precision float value. If either of the values is NaN, the result is false.

<br />

| Parameters ||
|---|---|
| `x` | `short`: The first half-precision value <br /> |
| `y` | `short`: The second half-precision value <br /> |

| Returns ||
|---|---|
| `boolean` | True if x is greater than y, false otherwise <br /> |

### halfToIntBits

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int halfToIntBits (short h)
```

<br />

Returns a representation of the specified half-precision float value according to the bit layout described in `https://developer.android.com/reference/android/util/Half`.

Unlike `https://developer.android.com/reference/android/util/Half#halfToRawIntBits(short)`, this method collapses all possible Not-a-Number values to a single canonical Not-a-Number value defined by `https://developer.android.com/reference/android/util/Half#NaN`.

<br />

<br />

| Parameters ||
|---|---|
| `h` | `short`: A half-precision float value <br /> |

| Returns ||
|---|---|
| `int` | The bits that represent the half-precision float value <br /> |

**See also:**

- `https://developer.android.com/reference/android/util/Half#halfToRawIntBits(short)`
- `https://developer.android.com/reference/android/util/Half#halfToShortBits(short)`
- `https://developer.android.com/reference/android/util/Half#intBitsToHalf(int)`

### halfToRawIntBits

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int halfToRawIntBits (short h)
```

<br />

Returns a representation of the specified half-precision float value according to the bit layout described in `https://developer.android.com/reference/android/util/Half`.

The argument is considered to be a representation of a half-precision float value according to the bit layout described in `https://developer.android.com/reference/android/util/Half`. The 16 most significant bits of the returned value are set to 0.

<br />

<br />

| Parameters ||
|---|---|
| `h` | `short`: A half-precision float value <br /> |

| Returns ||
|---|---|
| `int` | The bits that represent the half-precision float value <br /> |

**See also:**

- `https://developer.android.com/reference/android/util/Half#halfToIntBits(short)`
- `https://developer.android.com/reference/android/util/Half#intBitsToHalf(int)`

### halfToShortBits

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static short halfToShortBits (short h)
```

<br />

Returns a representation of the specified half-precision float value according to the bit layout described in `https://developer.android.com/reference/android/util/Half`.

Similar to `https://developer.android.com/reference/android/util/Half#halfToIntBits(short)`, this method collapses all possible Not-a-Number values to a single canonical Not-a-Number value defined by `https://developer.android.com/reference/android/util/Half#NaN`.

<br />

<br />

| Parameters ||
|---|---|
| `h` | `short`: A half-precision float value <br /> |

| Returns ||
|---|---|
| `short` | The bits that represent the half-precision float value <br /> |

**See also:**

- `https://developer.android.com/reference/android/util/Half#halfToIntBits(short)`

### halfValue

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public short halfValue ()
```

Returns the half-precision value of this `Half` as a `short` containing the bit representation described in `https://developer.android.com/reference/android/util/Half`.

<br />

| Returns ||
|---|---|
| `short` | The half-precision float value represented by this object <br /> |

### hashCode

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int hashCode (short h)
```

Returns a hash code for a half-precision float value.

<br />

| Parameters ||
|---|---|
| `h` | `short`: The value to hash <br /> |

| Returns ||
|---|---|
| `int` | A hash code value for a half-precision float value <br /> |

### hashCode

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int hashCode ()
```

Returns a hash code for this `Half` object. The result is the integer bit representation, exactly as produced by the method `https://developer.android.com/reference/android/util/Half#halfToIntBits(short)`, of the primitive half-precision float value represented by this `Half` object.

<br />

| Returns ||
|---|---|
| `int` | A hash code value for this object <br /> |

### intBitsToHalf

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static short intBitsToHalf (int bits)
```

<br />

Returns the half-precision float value corresponding to a given bit representation.

The argument is considered to be a representation of a half-precision float value according to the bit layout described in `https://developer.android.com/reference/android/util/Half`. The 16 most significant bits of the argument are ignored.

<br />

<br />

| Parameters ||
|---|---|
| `bits` | `int`: An integer <br /> |

| Returns ||
|---|---|
| `short` | The half-precision float value with the same bit pattern <br /> |

### intValue

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int intValue ()
```

Returns the value of this `Half` as a `int` after a narrowing primitive conversion.

<br />

| Returns ||
|---|---|
| `int` | The half-precision float value represented by this object converted to type `int` <br /> |

### isInfinite

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isInfinite (short h)
```

Returns true if the specified half-precision float value represents infinity, false otherwise.

<br />

| Parameters ||
|---|---|
| `h` | `short`: A half-precision float value <br /> |

| Returns ||
|---|---|
| `boolean` | True if the value is positive infinity or negative infinity, false otherwise <br /> |

### isNaN

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isNaN ()
```

Returns true if this `Half` value represents a Not-a-Number, false otherwise.

<br />

| Returns ||
|---|---|
| `boolean` | True if the value is a NaN, false otherwise <br /> |

### isNaN

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isNaN (short h)
```

Returns true if the specified half-precision float value represents a Not-a-Number, false otherwise.

<br />

| Parameters ||
|---|---|
| `h` | `short`: A half-precision float value <br /> |

| Returns ||
|---|---|
| `boolean` | True if the value is a NaN, false otherwise <br /> |

### isNormalized

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isNormalized (short h)
```

Returns true if the specified half-precision float value is normalized (does not have a subnormal representation). If the specified value is `https://developer.android.com/reference/android/util/Half#POSITIVE_INFINITY`, `https://developer.android.com/reference/android/util/Half#NEGATIVE_INFINITY`, `https://developer.android.com/reference/android/util/Half#POSITIVE_ZERO`, `https://developer.android.com/reference/android/util/Half#NEGATIVE_ZERO`, NaN or any subnormal number, this method returns false.

<br />

| Parameters ||
|---|---|
| `h` | `short`: A half-precision float value <br /> |

| Returns ||
|---|---|
| `boolean` | True if the value is normalized, false otherwise <br /> |

### less

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean less (short x, 
                short y)
```

Returns true if the first half-precision float value is less (smaller toward negative infinity) than the second half-precision float value. If either of the values is NaN, the result is false.

<br />

| Parameters ||
|---|---|
| `x` | `short`: The first half-precision value <br /> |
| `y` | `short`: The second half-precision value <br /> |

| Returns ||
|---|---|
| `boolean` | True if x is less than y, false otherwise <br /> |

### lessEquals

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean lessEquals (short x, 
                short y)
```

Returns true if the first half-precision float value is less (smaller toward negative infinity) than or equal to the second half-precision float value. If either of the values is NaN, the result is false.

<br />

| Parameters ||
|---|---|
| `x` | `short`: The first half-precision value <br /> |
| `y` | `short`: The second half-precision value <br /> |

| Returns ||
|---|---|
| `boolean` | True if x is less than or equal to y, false otherwise <br /> |

### longValue

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public long longValue ()
```

Returns the value of this `Half` as a `long` after a narrowing primitive conversion.

<br />

| Returns ||
|---|---|
| `long` | The half-precision float value represented by this object converted to type `long` <br /> |

### max

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static short max (short x, 
                short y)
```

Returns the larger of two half-precision float values (the value closest to positive infinity). Special values are handled in the following ways:

- If either value is NaN, the result is NaN
- `https://developer.android.com/reference/android/util/Half#POSITIVE_ZERO` is greater than `https://developer.android.com/reference/android/util/Half#NEGATIVE_ZERO`

<br />

<br />

| Parameters ||
|---|---|
| `x` | `short`: The first half-precision value <br /> |
| `y` | `short`: The second half-precision value <br /> |

| Returns ||
|---|---|
| `short` | The larger of the two specified half-precision values <br /> |

### min

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static short min (short x, 
                short y)
```

Returns the smaller of two half-precision float values (the value closest to negative infinity). Special values are handled in the following ways:

- If either value is NaN, the result is NaN
- `https://developer.android.com/reference/android/util/Half#NEGATIVE_ZERO` is smaller than `https://developer.android.com/reference/android/util/Half#POSITIVE_ZERO`

<br />

<br />

| Parameters ||
|---|---|
| `x` | `short`: The first half-precision value <br /> |
| `y` | `short`: The second half-precision value <br /> |

| Returns ||
|---|---|
| `short` | The smaller of the two specified half-precision values <br /> |

### parseHalf

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static short parseHalf (String s)
```

Returns the half-precision float value represented by the specified string. Calling this method is equivalent to calling `toHalf(Float.parseString(h))`. See `https://developer.android.com/reference/java/lang/Float#valueOf(java.lang.String)` for more information on the format of the string representation.

<br />

| Parameters ||
|---|---|
| `s` | `String`: The string to be parsed. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `short` | A half-precision float value represented by the string <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NumberFormatException` | if the string does not contain a parsable half-precision float value |

### round

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static short round (short h)
```

Returns the closest integral half-precision float value to the specified half-precision float value. Special values are handled in the following ways:

- If the specified half-precision float is NaN, the result is NaN
- If the specified half-precision float is infinity (negative or positive), the result is infinity (with the same sign)
- If the specified half-precision float is zero (negative or positive), the result is zero (with the same sign)

**Note:** Unlike the identically named `int java.lang.Math.round(float)` method, this returns a Half value stored in a short, **not** an actual short integer result.

<br />

| Parameters ||
|---|---|
| `h` | `short`: A half-precision float value <br /> |

| Returns ||
|---|---|
| `short` | The value of the specified half-precision float rounded to the nearest half-precision float value <br /> |

### shortValue

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public short shortValue ()
```

Returns the value of this `Half` as a `short` after a narrowing primitive conversion.

<br />

| Returns ||
|---|---|
| `short` | The half-precision float value represented by this object converted to type `short` <br /> |

### toFloat

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static float toFloat (short h)
```

<br />

Converts the specified half-precision float value into a single-precision float value. The following special cases are handled:

- If the input is `https://developer.android.com/reference/android/util/Half#NaN`, the returned value is `https://developer.android.com/reference/java/lang/Float#NaN`
- If the input is `https://developer.android.com/reference/android/util/Half#POSITIVE_INFINITY` or `https://developer.android.com/reference/android/util/Half#NEGATIVE_INFINITY`, the returned value is respectively `https://developer.android.com/reference/java/lang/Float#POSITIVE_INFINITY` or `https://developer.android.com/reference/java/lang/Float#NEGATIVE_INFINITY`
- If the input is 0 (positive or negative), the returned value is +/-0.0f
- Otherwise, the returned value is a normalized single-precision float value

<br />

<br />

| Parameters ||
|---|---|
| `h` | `short`: The half-precision float value to convert to single-precision <br /> |

| Returns ||
|---|---|
| `float` | A normalized single-precision float value <br /> |

### toHalf

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static short toHalf (float f)
```

<br />

Converts the specified single-precision float value into a half-precision float value. The following special cases are handled:

- If the input is NaN (see `https://developer.android.com/reference/java/lang/Float#isNaN(float)`), the returned value is `https://developer.android.com/reference/android/util/Half#NaN`
- If the input is `https://developer.android.com/reference/java/lang/Float#POSITIVE_INFINITY` or `https://developer.android.com/reference/java/lang/Float#NEGATIVE_INFINITY`, the returned value is respectively `https://developer.android.com/reference/android/util/Half#POSITIVE_INFINITY` or `https://developer.android.com/reference/android/util/Half#NEGATIVE_INFINITY`
- If the input is 0 (positive or negative), the returned value is `https://developer.android.com/reference/android/util/Half#POSITIVE_ZERO` or `https://developer.android.com/reference/android/util/Half#NEGATIVE_ZERO`
- If the input is a less than `https://developer.android.com/reference/android/util/Half#MIN_VALUE`, the returned value is flushed to `https://developer.android.com/reference/android/util/Half#POSITIVE_ZERO` or `https://developer.android.com/reference/android/util/Half#NEGATIVE_ZERO`
- If the input is a less than `https://developer.android.com/reference/android/util/Half#MIN_NORMAL`, the returned value is a denorm half-precision float
- Otherwise, the returned value is rounded to the nearest representable half-precision float value

<br />

<br />

| Parameters ||
|---|---|
| `f` | `float`: The single-precision float value to convert to half-precision <br /> |

| Returns ||
|---|---|
| `short` | A half-precision float value <br /> |

### toHexString

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String toHexString (short h)
```

<br />

Returns a hexadecimal string representation of the specified half-precision 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 `"p-14"`

<br />

<br />

| Parameters ||
|---|---|
| `h` | `short`: A half-precision float value <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | A hexadecimal string representation of the specified value. This value cannot be `null`. <br /> |

### toString

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String toString (short h)
```

Returns a string representation of the specified half-precision float value. Calling this method is equivalent to calling `Float.toString(toFloat(h))`. See `https://developer.android.com/reference/java/lang/Float#toString(float)` for more information on the format of the string representation.

<br />

| Parameters ||
|---|---|
| `h` | `short`: A half-precision float value <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | A string representation of the specified value. This value cannot be `null`. <br /> |

### toString

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Returns a string representation of the specified half-precision float value. See `https://developer.android.com/reference/android/util/Half#toString(short)` for more information.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | A string representation of this `Half` object. This value cannot be `null`. <br /> |

### trunc

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static short trunc (short h)
```

Returns the truncated half-precision float value of the specified half-precision float value. Special values are handled in the following ways:

- If the specified half-precision float is NaN, the result is NaN
- If the specified half-precision float is infinity (negative or positive), the result is infinity (with the same sign)
- If the specified half-precision float is zero (negative or positive), the result is zero (with the same sign)

<br />

<br />

| Parameters ||
|---|---|
| `h` | `short`: A half-precision float value <br /> |

| Returns ||
|---|---|
| `short` | The truncated half-precision float value of the specified half-precision float value <br /> |

### valueOf

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Half valueOf (String s)
```

Returns a `Half` instance representing the specified string value. Calling this method is equivalent to calling `toHalf(Float.parseString(h))`. See `https://developer.android.com/reference/java/lang/Float#valueOf(java.lang.String)` for more information on the format of the string representation.

<br />

| Parameters ||
|---|---|
| `s` | `String`: The string to be parsed. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/util/Half` | a `Half` instance representing `h` This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NumberFormatException` | if the string does not contain a parsable half-precision float value |

### valueOf

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Half valueOf (float f)
```

Returns a `Half` instance representing the specified float value.

<br />

| Parameters ||
|---|---|
| `f` | `float`: A float value <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/util/Half` | a `Half` instance representing `f` This value cannot be `null`. <br /> |

### valueOf

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Half valueOf (short h)
```

Returns a `Half` instance representing the specified half-precision float value.

<br />

| Parameters ||
|---|---|
| `h` | `short`: A half-precision float value <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/util/Half` | a `Half` instance representing `h` This value cannot be `null`. <br /> |