Top Description Fields Constructors Methods
com.jogamp.opengl.math

public final Class Binary16

extends Object
Class Inheritance

Functions to convert values to/from the binary16 format specified in IEEE 754 2008.

Field Summary

Modifier and TypeField and Description
public static final int
BIAS

The bias value used to offset the encoded exponent.

private static final int
private static final int
private static final int
public static final char
NEGATIVE_INFINITY

The encoded form of negative infinity -∞.

public static final char
NEGATIVE_ZERO

The encoded form of negative zero -0.

public static final char
POSITIVE_INFINITY

The encoded form of positive infinity ∞.

public static final char
POSITIVE_ZERO

The encoded form of positive zero 0.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static char
exampleNaN()

One possible not-a-number value.

public static boolean
isInfinite(final char k)

Return true if the given packed binary16 value is infinite.

public static boolean
isNaN(final char k)

Return true if the given packed binary16 value is not a number (NaN).

public static char
packDouble(final double k)

Convert a double precision floating point value to a packed binary16 value.

public static char
packFloat(final float k)

Convert a single precision floating point value to a packed binary16 value.

public static char
packSetExponentUnbiasedUnchecked(final int e)

Encode the unbiased exponent e.

public static char
packSetSignificandUnchecked(final int s)

Encode the significand s.

public static char
packSetSignUnchecked(final int s)

Encode the sign bit s.

public static String
toRawBinaryString(final char k)

Show the given raw packed binary16 value as a string of binary digits.

public static double
unpackDouble(final char k)

Convert a packed binary16 value k to a double-precision floating point value.

public static float
unpackFloat(final char k)

Convert a packed binary16 value k to a single-precision floating point value.

public static int
unpackGetExponentUnbiased(final char k)

Extract and unbias the exponent of the given packed binary16 value.

public static int
unpackGetSign(final char k)

Retrieve the sign bit of the given packed binary16 value, as an integer in the range [0, 1].

public static int
unpackGetSignificand(final char k)

Return the significand of the given packed binary16 value as an integer in the range [0, 1023].

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BIASback to summary
public static final int BIAS

The bias value used to offset the encoded exponent. A given exponent e is encoded as BIAS + e.

MASK_EXPONENTback to summary
private static final int MASK_EXPONENT
MASK_SIGNback to summary
private static final int MASK_SIGN
MASK_SIGNIFICANDback to summary
private static final int MASK_SIGNIFICAND
NEGATIVE_INFINITYback to summary
public static final char NEGATIVE_INFINITY

The encoded form of negative infinity -∞.

NEGATIVE_ZEROback to summary
public static final char NEGATIVE_ZERO

The encoded form of negative zero -0.

POSITIVE_INFINITYback to summary
public static final char POSITIVE_INFINITY

The encoded form of positive infinity ∞.

POSITIVE_ZEROback to summary
public static final char POSITIVE_ZERO

The encoded form of positive zero 0.

Constructor Detail

Binary16back to summary
private Binary16()

Method Detail

exampleNaNback to summary
public static char exampleNaN()

One possible not-a-number value.

isInfiniteback to summary
public static boolean isInfinite(final char k)

Return true if the given packed binary16 value is infinite.

isNaNback to summary
public static boolean isNaN(final char k)

Return true if the given packed binary16 value is not a number (NaN).

packDoubleback to summary
public static char packDouble(final double k)

Convert a double precision floating point value to a packed binary16 value.

For the following specific cases, the function returns:

Otherwise, the binary16 value that most closely represents k is returned. This may obviously be an infinite value as the interval of double precision values is far larger than that of the binary16 type.

See Also
unpackDouble(char)
packFloatback to summary
public static char packFloat(final float k)

Convert a single precision floating point value to a packed binary16 value.

For the following specific cases, the function returns:

Otherwise, the binary16 value that most closely represents k is returned. This may obviously be an infinite value as the interval of single precision values is far larger than that of the binary16 type.

See Also
unpackFloat(char)
packSetExponentUnbiasedUncheckedback to summary
public static char packSetExponentUnbiasedUnchecked(final int e)

Encode the unbiased exponent e. Values should be in the range [-15, 16] - values outside of this range will be truncated.

See Also
unpackGetExponentUnbiased(char)
packSetSignificandUncheckedback to summary
public static char packSetSignificandUnchecked(final int s)

Encode the significand s. Values should be in the range [0, 1023]. Values outside of this range will be truncated.

See Also
unpackGetSignificand(char)
packSetSignUncheckedback to summary
public static char packSetSignUnchecked(final int s)

Encode the sign bit s. Values should be in the range [0, 1], with 0 ironically denoting a positive value. Values outside of this range will be truncated.

See Also
unpackGetSign(char)
toRawBinaryStringback to summary
public static String toRawBinaryString(final char k)

Show the given raw packed binary16 value as a string of binary digits.

unpackDoubleback to summary
public static double unpackDouble(final char k)

Convert a packed binary16 value k to a double-precision floating point value.

The function returns:

See Also
packDouble(double)
unpackFloatback to summary
public static float unpackFloat(final char k)

Convert a packed binary16 value k to a single-precision floating point value.

The function returns:

See Also
packFloat(float)
unpackGetExponentUnbiasedback to summary
public static int unpackGetExponentUnbiased(final char k)

Extract and unbias the exponent of the given packed binary16 value.

The exponent is encoded biased as a number in the range [0, 31], with 0 indicating that the number is subnormal and [1, 30] denoting the actual exponent plus BIAS. Infinite and NaN values always have an exponent of 31.

This function will therefore return:

See Also
packSetExponentUnbiasedUnchecked(int)
unpackGetSignback to summary
public static int unpackGetSign(final char k)

Retrieve the sign bit of the given packed binary16 value, as an integer in the range [0, 1].

See Also
Binary16#packSetSignUnchecked(int)
unpackGetSignificandback to summary
public static int unpackGetSignificand(final char k)

Return the significand of the given packed binary16 value as an integer in the range [0, 1023].

See Also
Binary16#packSetSignificandUnchecked(int)