Class HalfMath

java.lang.Object
com.apple.foundationdb.half.HalfMath

public class HalfMath extends Object
The class HalfMath contains methods for performing basic numeric operations on or using Half objects.
  • Method Details

    • ulp

      public static Half ulp(Half half)
      Returns the size of an ulp of the argument. An ulp, unit in the last place, of a half value is the positive distance between this floating-point value and the half value next larger in magnitude.
      Note that for non-NaN x, ulp(-x) == ulp(x).

      Special Cases:

      • If the argument is NaN, then the result is NaN.
      • If the argument is positive or negative infinity, then the result is positive infinity.
      • If the argument is positive or negative zero, then the result is Float.MIN_VALUE.
      • If the argument is ±Half.MAX_VALUE, then the result is equal to 25.
      Parameters:
      half - the floating-point value whose ulp is to be returned
      Returns:
      the size of an ulp of the argument
    • getExponent

      public static int getExponent(Half half)
      Returns the unbiased exponent used in the representation of a half.

      Special cases:

      Parameters:
      half - a half value
      Returns:
      the unbiased exponent of the argument
    • abs

      public static Half abs(Half half)
      Returns the absolute Half object of a half instance.

      Special cases:

      • If the argument is positive zero or negative zero, the result is positive zero.
      • If the argument is infinite, the result is positive infinity.
      • If the argument is NaN, the result is a "canonical" NaN (preserving Not-a-Number (NaN) signaling).
      Parameters:
      half - the argument whose absolute value is to be determined
      Returns:
      the absolute value of the argument.