Package com.spun.util
Class NumberUtils
java.lang.Object
com.spun.util.NumberUtils
A static class of convenience functions for Manipulating numbers
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 booleanstatic doublestatic intLoads an int from a String.static intLoads an int from a String.static longLoads an int from a String.static int[]static voida unit test of sortsstatic doublesetSignificantDigit(double onNumber, int digit) static StringstripNonNumeric(String input) 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) -
stripNonNumeric
-
toIntStream
-
toIntStream
-
toIntStream
-
toLongStream
-
toLongStream
-
toLongStream
-
toDoubleStream
-
toDoubleStream
-
toDoubleStream
-