Class NumberUtils


  • public final class NumberUtils
    extends java.lang.Object
    Contains methods dealing with numbers.
    Since:
    1.4.0
    • Constructor Summary

      Constructors 
      Constructor Description
      NumberUtils()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static double cubed​(int input)
      Cubes the specified number.
      static java.lang.Boolean isEven​(int input)
      Checks if the specified number is even.
      static java.lang.Boolean isInRange​(int input, int lower, int upper, boolean inclusive)
      Checks if the specified number is in range.
      static java.lang.Boolean isOdd​(int input)
      Checks if the specified number is odd.
      boolean isPrime​(long input)
      Checks if the specified number is prime.
      static double squared​(int input)
      Squares the specified number.
      static double squareRoot​(int input)
      Returns the square root of the specified number.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NumberUtils

        public NumberUtils()
    • Method Detail

      • isPrime

        public boolean isPrime​(long input)
        Checks if the specified number is prime.
        Parameters:
        input - number to check
        Returns:
        true if specified number is prime
      • isEven

        public static java.lang.Boolean isEven​(int input)
        Checks if the specified number is even.
        Parameters:
        input - number to check
        Returns:
        true if the specified number is even
      • isOdd

        public static java.lang.Boolean isOdd​(int input)
        Checks if the specified number is odd.
        Parameters:
        input - number to check
        Returns:
        true if the specified number is odd
      • squared

        public static double squared​(int input)
        Squares the specified number.
        Parameters:
        input - number to edit
        Returns:
        the number squared
      • cubed

        public static double cubed​(int input)
        Cubes the specified number.
        Parameters:
        input - number to edit
        Returns:
        the number cubed
      • squareRoot

        public static double squareRoot​(int input)
        Returns the square root of the specified number.
        Parameters:
        input - number to edit
        Returns:
        the square root of the number
      • isInRange

        public static java.lang.Boolean isInRange​(int input,
                                                  int lower,
                                                  int upper,
                                                  boolean inclusive)
        Checks if the specified number is in range.
        Parameters:
        input - the number to check
        lower - the lower bound
        upper - the upper bound
        inclusive - if true the upper bound is included
        Returns:
        true if the specified number is in range