Package org.vast.util

Class NumberUtils

java.lang.Object
org.vast.util.NumberUtils

public class NumberUtils extends Object

Utility math functions

Since:
Apr 6, 2017
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    exactEquals(double d1, double d2)
    Exact double equality check
    static boolean
    exactEquals(float f1, float f2)
    Exact float equality check
    static boolean
    Checks that text is a number
    static boolean
    Checks that text is a number allowing for exponent
    static boolean
    ulpEquals(double d1, double d2)
    Checks that double arguments are within one ULP of each other
    static boolean
    ulpEquals(float f1, float f2)
    Checks that float arguments are within one ULP of each other

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • ulpEquals

      public static boolean ulpEquals(float f1, float f2)
      Checks that float arguments are within one ULP of each other
      Parameters:
      f1 -
      f2 -
      Returns:
      true if both numbers are within 1 ULP, false otherwise
    • ulpEquals

      public static boolean ulpEquals(double d1, double d2)
      Checks that double arguments are within one ULP of each other
      Parameters:
      d1 -
      d2 -
      Returns:
      true if both numbers are within 1 ULP of each other, false otherwise
    • exactEquals

      public static boolean exactEquals(float f1, float f2)
      Exact float equality check
      Parameters:
      f1 -
      f2 -
      Returns:
      true if float arguments have the same exact binary value
    • exactEquals

      public static boolean exactEquals(double d1, double d2)
      Exact double equality check
      Parameters:
      d1 -
      d2 -
      Returns:
      true if float arguments have the same exact binary value
    • isNumeric

      public static boolean isNumeric(String text)
      Checks that text is a number
      Parameters:
      text -
      Returns:
      true if the string is a valid base 10 integer or decimal number w/o exponent
    • isNumericExp

      public static boolean isNumericExp(String text)
      Checks that text is a number allowing for exponent
      Parameters:
      text -
      Returns:
      true if the string is a valid base 10 integer or decimal number, optionally with exponent notation