public final class NumericalUtility extends Object
CATION: This class may not have an optimized runtime behavior!
Modifier and Type | Method and Description |
---|---|
static int |
sum(int... aSummands)
Calculates the sum from the provided summands.
|
static boolean |
toBoolean(String aValue)
Converts the given String to a boolean value.
|
static byte[] |
toBytes(Double aDouble)
Converts a double value to an array of bytes, left(?)
|
static byte[] |
toBytes(int aInteger)
Converts a integer value to an array of bytes, left byte being the most
significant one (highest order).
|
static byte[] |
toBytes(long aLong)
Converts a long value to an array of bytes, left byte being the most
significant one (highest order).
|
static double |
toDouble(String aString)
Creates a double between 0 and 1 from a
String ; useful e.g. when
creating a number from a pass-phrase. |
static double[] |
toDoubles(String aString,
int aCount)
Creates an array with double values between 0 and 1 from a
String
; useful e.g. when creating a bunch of numbers from a pass-phrase. |
static int |
toHashCode(Object... aObjects)
Calculates a hash code from the given object's hash codes.
|
static int |
toInteger(byte[] aBytes)
To integer.
|
static int |
toInteger(byte[] aBytes,
int aOffset)
To integer.
|
static long |
toLong(byte[] aBytes)
To long.
|
static long |
toLong(byte[] aBytes,
int aOffset)
To long.
|
static long |
toLong(String aString)
Creates a long from a
String ; useful e.g. when creating a number
from a pass-phrase. |
static String |
toMd5Hash(String aText)
Generates a md5 hash of the given text.
|
static double |
toScaled(double aValue,
double aMin,
double aMax)
Scales the given value (which must be between 0 .. 1 to be between aMin
.. aMax.
|
static short[] |
toShorts(byte[] aBytes)
Converts a byte array to a short array.
|
static long |
toUnsignedLong(int aSignedIntValue)
Converts a signed int to an unsigned long value.
|
public static byte[] toBytes(long aLong)
aLong
- The long value to be convertedpublic static byte[] toBytes(int aInteger)
aInteger
- The integer value to be convertedpublic static long toLong(byte[] aBytes) throws IllegalArgumentException
aBytes
- the bytesIllegalArgumentException
- the illegal argument exceptionpublic static long toLong(byte[] aBytes, int aOffset) throws IllegalArgumentException
aBytes
- the bytesaOffset
- the offsetIllegalArgumentException
- the illegal argument exceptionpublic static int toInteger(byte[] aBytes) throws IllegalArgumentException
aBytes
- the bytesIllegalArgumentException
- the illegal argument exceptionpublic static int toInteger(byte[] aBytes, int aOffset) throws IllegalArgumentException
aBytes
- the bytesaOffset
- the offsetIllegalArgumentException
- the illegal argument exceptionpublic static short[] toShorts(byte[] aBytes)
aBytes
- The bytes to be converted to short.public static byte[] toBytes(Double aDouble)
aDouble
- The double value to be convertedpublic static long toLong(String aString)
String
; useful e.g. when creating a number
from a pass-phrase.public static double toDouble(String aString)
String
; useful e.g. when
creating a number from a pass-phrase.public static double[] toDoubles(String aString, int aCount)
String
; useful e.g. when creating a bunch of numbers from a pass-phrase.public static int toHashCode(Object... aObjects)
aObjects
- The objects for which to calculate the has codes.public static long toUnsignedLong(int aSignedIntValue)
aSignedIntValue
- The signed integer value.public static boolean toBoolean(String aValue) throws IllegalArgumentException
aValue
- The text value to be tested whether it represents true or
false.IllegalArgumentException
- in case neither true nor false could be
determined.public static String toMd5Hash(String aText)
aText
- The text to be md5 hashed.public static double toScaled(double aValue, double aMin, double aMax)
aValue
- The value between 0 .. 1 to be scaled.aMin
- The min value.aMax
- The max value.public static int sum(int... aSummands)
aSummands
- The summands to be added up.Copyright © 2018. All rights reserved.