Package com.spun.util

Class NumberUtils

java.lang.Object
com.spun.util.NumberUtils

public class NumberUtils extends Object
A static class of convenience functions for Manipulating numbers
  • Field Details

    • RANDOM

      public static Random RANDOM
  • Constructor Details

    • NumberUtils

      public NumberUtils()
  • Method Details

    • getMax

      public static int getMax(int value1, int value2)
    • load

      public static int load(String i, int defaultValue)
      Loads an int from a String.
    • load

      public static int load(String i, int defaultValue, boolean stripNonNumeric)
      Loads an int from a String.
    • load

      public static long load(String i, long defaultValue)
      Loads an int from a String.
    • load

      public static double load(String i, double defaultValue)
    • load

      public static boolean load(String i, boolean d)
    • loadArray

      public static int[] loadArray(String summaryString, String seperator, int defaultWhenLoading)
    • setSignificantDigit

      public static double setSignificantDigit(double onNumber, int digit)
    • main

      public static void main(String[] args)
      a unit test of sorts
    • doRandomPercentage

      public static boolean doRandomPercentage(int i)
    • equals

      public static boolean equals(double one, double two, double delta)
    • wrapIntegers

      public static Integer[] wrapIntegers(int[] ints)
    • createRandomStringOfNumbers

      public static String createRandomStringOfNumbers(int digits)
    • isIn

      public static boolean isIn(int check, int[] available)
    • isEven

      public static boolean isEven(int number)
    • getShuffled

      public static <T> T[] getShuffled(T[] objects, int numberToReturn)
    • getRandomInt

      public static int getRandomInt(int minimum, int maximum)
      randomly chooses a number between the minimum and maximum
      Example: int grade = NumberUtils.getRandomInt(1,100);
      Parameters:
      minimum - The lowest possible value (inclusive)
      maximum - The highest possible value (inclusive)
      Returns:
      the random number
    • floor

      public static int floor(double i)
    • getNumberOfDigits

      public static int getNumberOfDigits(int number)
    • convertDoubleToPercentage

      public static double convertDoubleToPercentage(double doub)
    • convertPercentageToDouble

      public static double convertPercentageToDouble(double percent)
    • stripNonNumeric

      public static String stripNonNumeric(String input)
    • toIntStream

      public static IntStream toIntStream(int[] numbers)
    • toIntStream

      public static IntStream toIntStream(Integer[] numbers)
    • toIntStream

      public static IntStream toIntStream(List<Integer> numbers)
    • toLongStream

      public static LongStream toLongStream(long[] numbers)
    • toLongStream

      public static LongStream toLongStream(Long[] numbers)
    • toLongStream

      public static LongStream toLongStream(List<Long> numbers)
    • toDoubleStream

      public static DoubleStream toDoubleStream(double[] numbers)
    • toDoubleStream

      public static DoubleStream toDoubleStream(Double[] numbers)
    • toDoubleStream

      public static DoubleStream toDoubleStream(List<Double> numbers)