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
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNumberUtils.Shuffler -
Field Summary
-
Constructor Summary
Constructors Constructor Description NumberUtils() -
Method Summary
Modifier and Type Method Description static doubleconvertDoubleToPercentage(double doub)static doubleconvertPercentageToDouble(double percent)static StringcreateRandomStringOfNumbers(int digits)static booleandoRandomPercentage(int i)static booleanequals(double one, double two, double delta)static intfloor(double i)static intgetMax(int value1, int value2)static intgetNumberOfDigits(int number)static intgetRandomInt(int minimum, int maximum)randomly chooses a number between the minimum and maximum Example:int grade = NumberUtils.getRandomInt(1,100);static <T> T[]getShuffled(T[] objects, int numberToReturn)static booleanisEven(int number)static booleanisIn(int check, int[] available)static booleanload(String i, boolean d)static doubleload(String i, double defaultValue)static intload(String i, int defaultValue)Loads an int from a String.static intload(String i, int defaultValue, boolean stripNonNumeric)Loads an int from a String.static longload(String i, long defaultValue)Loads an int from a String.static int[]loadArray(String summaryString, String seperator, int defaultWhenLoading)static voidmain(String[] args)a unit test of sortsstatic doublesetSignificantDigit(double onNumber, int digit)static DoubleStreamtoDoubleStream(double[] numbers)static DoubleStreamtoDoubleStream(Double[] numbers)static DoubleStreamtoDoubleStream(List<Double> numbers)static IntStreamtoIntStream(int[] numbers)static IntStreamtoIntStream(Integer[] numbers)static IntStreamtoIntStream(List<Integer> numbers)static LongStreamtoLongStream(long[] numbers)static LongStreamtoLongStream(Long[] numbers)static LongStreamtoLongStream(List<Long> numbers)static Integer[]wrapIntegers(int[] ints)
-
Field Details
-
RANDOM
-
-
Constructor Details
-
NumberUtils
public NumberUtils()
-
-
Method Details
-
getMax
public static int getMax(int value1, int value2) -
load
Loads an int from a String. -
load
Loads an int from a String. -
load
Loads an int from a String. -
load
-
load
-
loadArray
-
setSignificantDigit
public static double setSignificantDigit(double onNumber, int digit) -
main
a unit test of sorts -
doRandomPercentage
public static boolean doRandomPercentage(int i) -
equals
public static boolean equals(double one, double two, double delta) -
wrapIntegers
-
createRandomStringOfNumbers
-
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 maximumExample: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) -
toIntStream
-
toIntStream
-
toIntStream
-
toLongStream
-
toLongStream
-
toLongStream
-
toDoubleStream
-
toDoubleStream
-
toDoubleStream
-