Class NumericalUtility


  • public final class NumericalUtility
    extends Object
    This class contains some useful static methods for working with bitwise operations objects.

    CATION: This class may not have an optimized runtime behavior!

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isBitSetAt​(long aValue, int aPosition)
      Determines the whether a bit at a given position of the provided is set.
      static byte setBitAt​(byte aValue, int aPos, boolean aBit)
      Sets the bit of the given value at the given bit position as specified.
      static int sum​(int... aSummands)
      Calculates the sum from the provided summands.
      static byte[] toBigEndianBytes​(double aValue)
      Converts the given value to a byte array in big endian notation.
      static byte[] toBigEndianBytes​(float aValue)
      Converts the given value to a byte array in big endian notation.
      static byte[] toBigEndianBytes​(int aValue)
      Converts the given value to a byte array in big endian notation.
      static byte[] toBigEndianBytes​(long aValue)
      Converts the given value to a byte array in big endian notation.
      static byte[] toBigEndianBytes​(long aValue, int aLength)
      Converts the given value to a byte array in big endian notation.
      static byte[] toBigEndianBytes​(short aValue)
      Converts the given value to a byte array in big endian notation.
      static boolean toBoolean​(String aValue)
      Converts the given String to a boolean value.
      static boolean[] toBooleans​(byte[] aBytes)
      Converts the bits contained within the given byte array to a boolean array.
      static boolean[] toBooleans​(byte[] aBytes, int aLength)
      Converts the bits contained within the given byte array to a boolean array.
      static boolean[] toBooleans​(byte[] aBytes, int aOffset, int aLength)
      Converts the bits contained within the given byte array to a boolean array.
      static byte[] toBytes​(boolean[] aBits)
      Converts a boolean array to a byte array using the byte's bits to represent the according boolean values.
      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 byte[] toBytes​(Double aDouble)
      Converts a double value to an array of bytes, left(?)
      static byte[] toBytes​(String aString)
      Converts a String containing "verbose" bytes into an array of bytes.
      static byte[] toBytes​(String aString, boolean isHexString)
      Converts a String containing "verbose" bytes into an array of bytes.
      static double toDouble​(int aIntValue, double aMinDouble, double aMaxDouble)
      Converts the given integer value to a double of the given range.
      static double toDouble​(long aLongValue, double aMinDouble, double aMaxDouble)
      Converts the given long value to a double of the given range.
      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 toDoubleFromBigEndianBytes​(byte[] aBigEndian)
      Converts a byte array in big endian to a double value.
      static double toDoubleFromLittleEndianBytes​(byte[] aLittleEndian)
      Converts a byte array in big little to a double value.
      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 float toFloatFromBigEndianBytes​(byte[] aBigEndian)
      Converts a byte array in big endian to a float value.
      static float toFloatFromLittleEndianBytes​(byte[] aLittleEndian)
      Converts a byte array in big little to a float value.
      static int toHashCode​(Object... aObjects)
      Calculates a hash code from the given object's hash codes.
      static int toHashCode​(String aValue)
      Calculates a Java-Version's implementation independent Hash-Code.
      static int[] toHashCodes​(char[] aSource, int aCount)
      Creates a given number of IDs from the provided source text.
      static int[] toHashCodes​(String aSource, int aCount)
      Creates a given number of IDs from the provided source text.
      static String toHexString​(byte aByte)
      Converts the provided byte to a hexadecimal String representation.
      static String toHexString​(byte... aBytes)
      Converts the provided bytes to a hexadecimal String representation.
      static String toHexString​(byte[] aBytes, int aBytesPerLine)
      Converts the provided bytes to a hexadecimal String representation.
      static String toHexString​(byte[] aBytes, String aByteSeparator)
      Converts the provided bytes to a hexadecimal String representation.
      static String toHexString​(byte[] aBytes, String aByteSeparator, int aBytesPerLine)
      Converts the provided bytes to a hexadecimal String representation.
      static String toHexString​(int aBytesPerLine, byte... aBytes)
      Converts the provided bytes to a hexadecimal String representation.
      static String toHexString​(String aByteSeparator, byte... aBytes)
      Converts the provided bytes to a hexadecimal String representation.
      static String toHexString​(String aByteSeparator, int aBytesPerLine, byte... aBytes)
      Converts the provided bytes to a hexadecimal String representation.
      static int toInt​(byte[] aBytes)
      Converts an integer value from the given byte array.
      static int toInt​(byte[] aBytes, int aOffset)
      Converts an integer value from the given byte array.
      static int toIntFromBigEndianBytes​(byte[] aBigEndian)
      Converts a byte array in big endian to an integer value.
      static int toIntFromLittleEndianBytes​(byte[] aLittleEndian)
      Converts a byte array in little endian to an integer value.
      static byte[] toLittleEndianBytes​(double aValue)
      Converts the given value to a byte array in big endian notation.
      static byte[] toLittleEndianBytes​(float aValue)
      Converts the given value to a byte array in big endian notation.
      static byte[] toLittleEndianBytes​(int aValue)
      Converts the given value to a byte array in little endian notation.
      static byte[] toLittleEndianBytes​(long aValue)
      Converts the given value to a byte array in little endian notation.
      static byte[] toLittleEndianBytes​(long aValue, int aLength)
      Converts the given value to a byte array in little endian notation.
      static byte[] toLittleEndianBytes​(short aValue)
      Converts the given value to a byte array in little endian notation.
      static long toLong​(byte[] aBytes)
      Converts a long value from the given byte array.
      static long toLong​(byte[] aBytes, int aOffset)
      Converts a long value from the given byte array.
      static long toLong​(String aString)
      Creates a long from a String; useful e.g. when creating a number from a pass-phrase.
      static long toLongFromBigEndianBytes​(byte[] aBigEndian)
      Converts a byte array in big endian to a long value.
      static long toLongFromLittleEndianBytes​(byte[] aLittleEndian)
      Converts a byte array in little endian to a long value.
      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 toShortFromBigEndianBytes​(byte[] aBigEndian)
      Converts a byte array in big endian to an short value.
      static short toShortFromLittleEndianBytes​(byte[] aLittleEndian)
      Converts a byte array in little endian to an short value.
      static short[] toShorts​(byte[] aBytes)
      Converts a byte array to a short array.
      static byte[] toUnsignedBigEndianBytes​(byte[] aBigEndian)
      Converts the given byte array to a byte array representing an unsigned value.
      static byte[] toUnsignedBigEndianBytes​(int aValue)
      Converts the given "unsigned" (it is to be treated as if it were unsigned) value to a byte array in big endian notation.
      static byte[] toUnsignedBigEndianBytes​(long aValue)
      Converts the given "unsigned" (it is to be treated as if it were unsigned) value to a byte array in big endian notation.
      static byte[] toUnsignedBigEndianBytes​(long aValue, int aLength)
      Converts the given "unsigned" (it is to be treated as if it were unsigned) value to a byte array in big endian notation.
      static byte[] toUnsignedBigEndianBytes​(short aValue)
      Converts the given "unsigned" (it is to be treated as if it were unsigned) value to a byte array in big endian notation.
      static int toUnsignedIntFromBigEndianBytes​(byte[] aBigEndian)
      Converts the given "unsigned" (it is to be treated as if it were unsigned) byte array in big endian to a long value.
      static int toUnsignedIntFromLittleEndianBytes​(byte[] aLittleEndian)
      Converts the given "unsigned" (it is to be treated as if it were unsigned) byte array in big endian to a long value.
      static byte[] toUnsignedLittleEndianBytes​(byte[] aLittleEndian)
      Converts the given byte array to a byte array representing an unsigned value.
      static byte[] toUnsignedLittleEndianBytes​(int aValue)
      Converts the given "unsigned" (it is to be treated as if it were unsigned) value to a byte array in little endian notation.
      static byte[] toUnsignedLittleEndianBytes​(long aValue)
      Converts the given "unsigned" (it is to be treated as if it were unsigned) value to a byte array in little endian notation.
      static byte[] toUnsignedLittleEndianBytes​(long aValue, int aLength)
      Converts the given "unsigned" (it is to be treated as if it were unsigned) value to a byte array in little endian notation.
      static byte[] toUnsignedLittleEndianBytes​(short aValue)
      Converts the given "unsigned" (it is to be treated as if it were unsigned) value to a byte array in little endian notation.
      static long toUnsignedLong​(int aSignedIntValue)
      Converts a signed int to an unsigned long value.
      static long toUnsignedLongFromBigEndianBytes​(byte[] aBigEndian)
      Converts the given "unsigned" (it is to be treated as if it were unsigned)a byte array in big endian to a long value.
      static long toUnsignedLongFromLittleEndianBytes​(byte[] aLittleEndian)
      Converts the given "unsigned" (it is to be treated as if it were unsigned) byte array in little endian to a long value.
      static short toUnsignedShortFromBigEndianBytes​(byte[] aBigEndian)
      Converts the given "unsigned" (it is to be treated as if it were unsigned) byte array in big endian to a long value.
      static short toUnsignedShortFromLittleEndianBytes​(byte[] aLittleEndian)
      Converts the given "unsigned" (it is to be treated as if it were unsigned) byte array in big endian to a long value.
    • Method Detail

      • isBitSetAt

        public static boolean isBitSetAt​(long aValue,
                                         int aPosition)
        Determines the whether a bit at a given position of the provided is set.
        Parameters:
        aValue - The value which's bits to test.
        aPosition - The position of the bit in question.
        Returns:
        True in case it is set, else false,
      • setBitAt

        public static byte setBitAt​(byte aValue,
                                    int aPos,
                                    boolean aBit)
        Sets the bit of the given value at the given bit position as specified.
        Parameters:
        aValue - The value where to set the bit.
        aPos - The bit of the value which to set accordingly.
        aBit - The value of the bit.
        Returns:
        The byte with the according bit set accordingly.
      • toBytes

        public static byte[] toBytes​(String aString)
                              throws IllegalArgumentException,
                                     NumberFormatException
        Converts a String containing "verbose" bytes into an array of bytes. The String might look as follows: "100,12,0x14, 0xFF". Hexadecimal values must(!) be prefixed with "X0" or "x0"!
        Parameters:
        aString - The String which is to be converted into bytes.
        Returns:
        The according byte array.
        Throws:
        IllegalArgumentException - in case the provided String contains illegal characters.
        NumberFormatException - in case the String contains values which cannot be parsed.
      • toBytes

        public static byte[] toBytes​(String aString,
                                     boolean isHexString)
                              throws IllegalArgumentException,
                                     NumberFormatException
        Converts a String containing "verbose" bytes into an array of bytes. The String might look as follows: "100,12,0x14, 0xFF"
        Parameters:
        aString - The String which is to be converted into bytes.
        isHexString - True in case you provide a hexadecimal String which may not have "0X" prefixed to its values. E.g. each value is treated as being hexadecimal.
        Returns:
        The according byte array.
        Throws:
        IllegalArgumentException - in case the provided String contains illegal characters.
        NumberFormatException - in case the String contains values which cannot be parsed.
      • toBytes

        public static byte[] toBytes​(long aLong)
        Converts a long value to an array of bytes, left byte being the most significant one (highest order).
        Parameters:
        aLong - The long value to be converted
        Returns:
        The array of bytes representing the long value.
      • toBytes

        public static byte[] toBytes​(int aInteger)
        Converts a integer value to an array of bytes, left byte being the most significant one (highest order).
        Parameters:
        aInteger - The integer value to be converted
        Returns:
        The array of bytes representing the long value.
      • toBytes

        public static byte[] toBytes​(boolean[] aBits)
        Converts a boolean array to a byte array using the byte's bits to represent the according boolean values. Attention: Trailing bits of the last byte might need to be ignored in case the length of the boolean array is not a multiple of 8.
        Parameters:
        aBits - The boolean array to convert.
        Returns:
        The byte array which's bits represent the according boolean array's values.
      • toBooleans

        public static boolean[] toBooleans​(byte[] aBytes)
        Converts the bits contained within the given byte array to a boolean array.
        Parameters:
        aBytes - The bytes to be converted.
        Returns:
        The according boolean array.
      • toBooleans

        public static boolean[] toBooleans​(byte[] aBytes,
                                           int aLength)
        Converts the bits contained within the given byte array to a boolean array.
        Parameters:
        aBytes - The bytes to be converted.
        aLength - The length of the resulting boolean array.
        Returns:
        The according boolean array.
      • toBooleans

        public static boolean[] toBooleans​(byte[] aBytes,
                                           int aOffset,
                                           int aLength)
        Converts the bits contained within the given byte array to a boolean array.
        Parameters:
        aBytes - The bytes to be converted.
        aOffset - The offset of the bytes from where to start converting.
        aLength - The length of the resulting boolean array.
        Returns:
        The according boolean array.
      • toLong

        public static long toLong​(byte[] aBytes)
        Converts a long value from the given byte array.
        Parameters:
        aBytes - The bytes to convert.
        Returns:
        The resulting long value.
      • toLong

        public static long toLong​(byte[] aBytes,
                                  int aOffset)
                           throws IllegalArgumentException
        Converts a long value from the given byte array.
        Parameters:
        aBytes - The bytes to convert.
        aOffset - The offset from where to start conversion.
        Returns:
        The resulting long value.
        Throws:
        IllegalArgumentException
      • toInt

        public static int toInt​(byte[] aBytes)
        Converts an integer value from the given byte array.
        Parameters:
        aBytes - The bytes to convert.
        Returns:
        The resulting integer value.
      • toInt

        public static int toInt​(byte[] aBytes,
                                int aOffset)
        Converts an integer value from the given byte array.
        Parameters:
        aBytes - The bytes to convert.
        aOffset - The offset from where to start conversion.
        Returns:
        The resulting integer value.
      • toShorts

        public static short[] toShorts​(byte[] aBytes)
        Converts a byte array to a short array.
        Parameters:
        aBytes - The bytes to be converted to short.
        Returns:
        The according short array.
      • toBytes

        public static byte[] toBytes​(Double aDouble)
        Converts a double value to an array of bytes, left(?) byte being the most significant one (highest order).
        Parameters:
        aDouble - The double value to be converted
        Returns:
        The array of bytes representing the double value.
      • toLong

        public static long toLong​(String aString)
        Creates a long from a String; useful e.g. when creating a number from a pass-phrase.
        Parameters:
        aString - The String to be converted to a long value.
        Returns:
        The long value from the String
      • toDouble

        public 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.
        Parameters:
        aString - The String to be converted to a double value.
        Returns:
        The double value between 0 and 1 from the String.
      • toDoubles

        public 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.
        Parameters:
        aString - The String to be converted to a double value.
        aCount - The number of doubles to create.
        Returns:
        The array with double values between 0 and 1 from the String.
      • toHashCode

        public static int toHashCode​(Object... aObjects)
        Calculates a hash code from the given object's hash codes.
        Parameters:
        aObjects - The objects for which to calculate the has codes.
        Returns:
        The hash codes for the given objects.
      • toUnsignedLong

        public static long toUnsignedLong​(int aSignedIntValue)
        Converts a signed int to an unsigned long value. This is not do a simple ABS function, here we take a look at the bits of the value and calculate which the unsigned (positive) value would be. The positive value is returned in a (signed) long value.
        Parameters:
        aSignedIntValue - The signed integer value.
        Returns:
        The unsigned long value.
      • toLittleEndianBytes

        public static byte[] toLittleEndianBytes​(long aValue,
                                                 int aLength)
        Converts the given value to a byte array in little endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        aLength - The number of bytes to use.
        Returns:
        The according array.
      • toLittleEndianBytes

        public static byte[] toLittleEndianBytes​(long aValue)
        Converts the given value to a byte array in little endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toLittleEndianBytes

        public static byte[] toLittleEndianBytes​(int aValue)
        Converts the given value to a byte array in little endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toLittleEndianBytes

        public static byte[] toLittleEndianBytes​(short aValue)
        Converts the given value to a byte array in little endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toBigEndianBytes

        public static byte[] toBigEndianBytes​(long aValue,
                                              int aLength)
        Converts the given value to a byte array in big endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        aLength - The number of bytes to use.
        Returns:
        The according array,
      • toBigEndianBytes

        public static byte[] toBigEndianBytes​(long aValue)
        Converts the given value to a byte array in big endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toBigEndianBytes

        public static byte[] toBigEndianBytes​(int aValue)
        Converts the given value to a byte array in big endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toBigEndianBytes

        public static byte[] toBigEndianBytes​(short aValue)
        Converts the given value to a byte array in big endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toUnsignedLittleEndianBytes

        public static byte[] toUnsignedLittleEndianBytes​(long aValue,
                                                         int aLength)
        Converts the given "unsigned" (it is to be treated as if it were unsigned) value to a byte array in little endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        aLength - The number of bytes to use.
        Returns:
        The according array.
      • toUnsignedLittleEndianBytes

        public static byte[] toUnsignedLittleEndianBytes​(long aValue)
        Converts the given "unsigned" (it is to be treated as if it were unsigned) value to a byte array in little endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toUnsignedLittleEndianBytes

        public static byte[] toUnsignedLittleEndianBytes​(int aValue)
        Converts the given "unsigned" (it is to be treated as if it were unsigned) value to a byte array in little endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toUnsignedLittleEndianBytes

        public static byte[] toUnsignedLittleEndianBytes​(short aValue)
        Converts the given "unsigned" (it is to be treated as if it were unsigned) value to a byte array in little endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toUnsignedBigEndianBytes

        public static byte[] toUnsignedBigEndianBytes​(long aValue,
                                                      int aLength)
        Converts the given "unsigned" (it is to be treated as if it were unsigned) value to a byte array in big endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        aLength - The number of bytes to use.
        Returns:
        The according array.
      • toUnsignedBigEndianBytes

        public static byte[] toUnsignedBigEndianBytes​(long aValue)
        Converts the given "unsigned" (it is to be treated as if it were unsigned) value to a byte array in big endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toUnsignedBigEndianBytes

        public static byte[] toUnsignedBigEndianBytes​(int aValue)
        Converts the given "unsigned" (it is to be treated as if it were unsigned) value to a byte array in big endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toUnsignedBigEndianBytes

        public static byte[] toUnsignedBigEndianBytes​(short aValue)
        Converts the given "unsigned" (it is to be treated as if it were unsigned) value to a byte array in big endian notation.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toLongFromLittleEndianBytes

        public static long toLongFromLittleEndianBytes​(byte[] aLittleEndian)
        Converts a byte array in little endian to a long value.
        Parameters:
        aLittleEndian - The byte array to be converted.
        Returns:
        The resulting long value.
      • toUnsignedLongFromLittleEndianBytes

        public static long toUnsignedLongFromLittleEndianBytes​(byte[] aLittleEndian)
        Converts the given "unsigned" (it is to be treated as if it were unsigned) byte array in little endian to a long value.
        Parameters:
        aLittleEndian - The byte array to be converted.
        Returns:
        The resulting long value.
      • toLongFromBigEndianBytes

        public static long toLongFromBigEndianBytes​(byte[] aBigEndian)
        Converts a byte array in big endian to a long value.
        Parameters:
        aBigEndian - The byte array to be converted.
        Returns:
        The resulting long value.
      • toUnsignedLongFromBigEndianBytes

        public static long toUnsignedLongFromBigEndianBytes​(byte[] aBigEndian)
        Converts the given "unsigned" (it is to be treated as if it were unsigned)a byte array in big endian to a long value.
        Parameters:
        aBigEndian - The byte array to be converted.
        Returns:
        The resulting long value.
      • toIntFromLittleEndianBytes

        public static int toIntFromLittleEndianBytes​(byte[] aLittleEndian)
        Converts a byte array in little endian to an integer value.
        Parameters:
        aLittleEndian - The byte array to be converted.
        Returns:
        The resulting integer value.
      • toUnsignedIntFromLittleEndianBytes

        public static int toUnsignedIntFromLittleEndianBytes​(byte[] aLittleEndian)
        Converts the given "unsigned" (it is to be treated as if it were unsigned) byte array in big endian to a long value.
        Parameters:
        aLittleEndian - The byte array to be converted.
        Returns:
        The resulting long value.
      • toIntFromBigEndianBytes

        public static int toIntFromBigEndianBytes​(byte[] aBigEndian)
        Converts a byte array in big endian to an integer value.
        Parameters:
        aBigEndian - The byte array to be converted.
        Returns:
        The resulting integer value.
      • toUnsignedIntFromBigEndianBytes

        public static int toUnsignedIntFromBigEndianBytes​(byte[] aBigEndian)
        Converts the given "unsigned" (it is to be treated as if it were unsigned) byte array in big endian to a long value.
        Parameters:
        aBigEndian - The byte array to be converted.
        Returns:
        The resulting long value.
      • toShortFromLittleEndianBytes

        public static short toShortFromLittleEndianBytes​(byte[] aLittleEndian)
        Converts a byte array in little endian to an short value.
        Parameters:
        aLittleEndian - The byte array to be converted.
        Returns:
        The resulting short value.
      • toUnsignedShortFromLittleEndianBytes

        public static short toUnsignedShortFromLittleEndianBytes​(byte[] aLittleEndian)
        Converts the given "unsigned" (it is to be treated as if it were unsigned) byte array in big endian to a long value.
        Parameters:
        aLittleEndian - The byte array to be converted.
        Returns:
        The resulting long value.
      • toShortFromBigEndianBytes

        public static short toShortFromBigEndianBytes​(byte[] aBigEndian)
        Converts a byte array in big endian to an short value.
        Parameters:
        aBigEndian - The byte array to be converted.
        Returns:
        The resulting short value.
      • toUnsignedShortFromBigEndianBytes

        public static short toUnsignedShortFromBigEndianBytes​(byte[] aBigEndian)
        Converts the given "unsigned" (it is to be treated as if it were unsigned) byte array in big endian to a long value.
        Parameters:
        aBigEndian - The byte array to be converted.
        Returns:
        The resulting long value.
      • toUnsignedLittleEndianBytes

        public static byte[] toUnsignedLittleEndianBytes​(byte[] aLittleEndian)
        Converts the given byte array to a byte array representing an unsigned value.
        Parameters:
        aLittleEndian - The byte array to be converted to be unsigned.
        Returns:
        The unsigned byte array, usually one byte longer.
      • toUnsignedBigEndianBytes

        public static byte[] toUnsignedBigEndianBytes​(byte[] aBigEndian)
        Converts the given byte array to a byte array representing an unsigned value.
        Parameters:
        aBigEndian - The byte array to be converted to be unsigned.
        Returns:
        The unsigned byte array, usually one byte longer.
      • toFloatFromBigEndianBytes

        public static float toFloatFromBigEndianBytes​(byte[] aBigEndian)
        Converts a byte array in big endian to a float value.
        Parameters:
        aBigEndian - The byte array to be converted.
        Returns:
        The resulting float value.
      • toFloatFromLittleEndianBytes

        public static float toFloatFromLittleEndianBytes​(byte[] aLittleEndian)
        Converts a byte array in big little to a float value.
        Parameters:
        aLittleEndian - The byte array to be converted.
        Returns:
        The resulting float value.
      • toBigEndianBytes

        public static byte[] toBigEndianBytes​(float aValue)
        Converts the given value to a byte array in big endian notation. The length for a long are 32 bits, so the result will be 4 bytes long.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toLittleEndianBytes

        public static byte[] toLittleEndianBytes​(float aValue)
        Converts the given value to a byte array in big endian notation. The length for a long are 32 bits, so the result will be 4 bytes long.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toDoubleFromBigEndianBytes

        public static double toDoubleFromBigEndianBytes​(byte[] aBigEndian)
        Converts a byte array in big endian to a double value.
        Parameters:
        aBigEndian - The byte array to be converted.
        Returns:
        The resulting double value.
      • toDoubleFromLittleEndianBytes

        public static double toDoubleFromLittleEndianBytes​(byte[] aLittleEndian)
        Converts a byte array in big little to a double value.
        Parameters:
        aLittleEndian - The byte array to be converted.
        Returns:
        The resulting double value.
      • toBigEndianBytes

        public static byte[] toBigEndianBytes​(double aValue)
        Converts the given value to a byte array in big endian notation. The length for a long are 64 bits, so the result will be 4 bytes long.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toLittleEndianBytes

        public static byte[] toLittleEndianBytes​(double aValue)
        Converts the given value to a byte array in big endian notation. The length for a long are 64 bits, so the result will be 4 bytes long.
        Parameters:
        aValue - The value for which to get the byte array.
        Returns:
        The according array.
      • toHexString

        public static String toHexString​(byte... aBytes)
        Converts the provided bytes to a hexadecimal String representation.
        Parameters:
        aBytes - The bytes for which to get the hexadecimal String.
        Returns:
        The according String.
      • toHexString

        public static String toHexString​(int aBytesPerLine,
                                         byte... aBytes)
        Converts the provided bytes to a hexadecimal String representation.
        Parameters:
        aBytesPerLine - The number of bytes to put on one line before inserting a line separator.
        aBytes - The bytes for which to get the hexadecimal String.
        Returns:
        The according String.
      • toHexString

        public static String toHexString​(String aByteSeparator,
                                         byte... aBytes)
        Converts the provided bytes to a hexadecimal String representation.
        Parameters:
        aBytes - The bytes for which to get the hexadecimal String.
        aByteSeparator - The separator to separate two hex values from each other or null if no separator is to be used.
        Returns:
        The according String.
      • toHexString

        public static String toHexString​(String aByteSeparator,
                                         int aBytesPerLine,
                                         byte... aBytes)
        Converts the provided bytes to a hexadecimal String representation.
        Parameters:
        aByteSeparator - The separator to separate two hex values from each other or null if no separator is to be used.
        aBytesPerLine - The number of bytes to put on one line before inserting a line separator.
        aBytes - The bytes for which to get the hexadecimal String.
        Returns:
        The according String.
      • toHexString

        public static String toHexString​(byte[] aBytes,
                                         String aByteSeparator)
        Converts the provided bytes to a hexadecimal String representation.
        Parameters:
        aBytes - The bytes for which to get the hexadecimal String.
        aByteSeparator - The separator to separate two hex values from each other or null if no separator is to be used.
        Returns:
        The according String.
      • toHexString

        public static String toHexString​(byte[] aBytes,
                                         int aBytesPerLine)
        Converts the provided bytes to a hexadecimal String representation.
        Parameters:
        aBytes - The bytes for which to get the hexadecimal String.
        aBytesPerLine - The number of bytes to put on one line before inserting a line separator.
        Returns:
        The according String.
      • toHexString

        public static String toHexString​(byte[] aBytes,
                                         String aByteSeparator,
                                         int aBytesPerLine)
        Converts the provided bytes to a hexadecimal String representation.
        Parameters:
        aBytes - The bytes for which to get the hexadecimal String.
        aByteSeparator - The separator to separate two hex values from each other or null if no separator is to be used.
        aBytesPerLine - The number of bytes to put on one line before inserting a line separator.
        Returns:
        The according String.
      • toHexString

        public static String toHexString​(byte aByte)
        Converts the provided byte to a hexadecimal String representation.
        Parameters:
        aByte - The byte for which to get the hexadecimal String.
        Returns:
        The according String.
      • toBoolean

        public static boolean toBoolean​(String aValue)
                                 throws IllegalArgumentException
        Converts the given String to a boolean value. Accepted values for a "true" boolean are "1", "on", "yes", "true". Accepted values for a "false" boolean are "0", "off", "no", "false".
        Parameters:
        aValue - The text value to be tested whether it represents true or false.
        Returns:
        True or false depending on the value passed.n
        Throws:
        IllegalArgumentException - in case neither true nor false could be determined.
      • toMd5Hash

        public static String toMd5Hash​(String aText)
                                throws NoSuchAlgorithmException
        Generates a md5 hash of the given text.
        Parameters:
        aText - The text to be md5 hashed.
        Returns:
        The md5 hashed text.
        Throws:
        NoSuchAlgorithmException - thrown in case the MD5 algorithm cannot be found on the classpath.
      • toScaled

        public static double toScaled​(double aValue,
                                      double aMin,
                                      double aMax)
        Scales the given value (which must be between 0 .. 1 to be between aMin .. aMax.
        Parameters:
        aValue - The value between 0 .. 1 to be scaled.
        aMin - The min value.
        aMax - The max value.
        Returns:
        A value between aMin ... aMax.
      • sum

        public static int sum​(int... aSummands)
        Calculates the sum from the provided summands.
        Parameters:
        aSummands - The summands to be added up.
        Returns:
        The sum of the provided summands.
      • toDouble

        public static double toDouble​(int aIntValue,
                                      double aMinDouble,
                                      double aMaxDouble)
        Converts the given integer value to a double of the given range.
        Parameters:
        aIntValue - The integer value which to convert accordingly
        aMinDouble - The lower bounds of the double value.
        aMaxDouble - The upper bounds of the double value.
        Returns:
        The accordingly converted value.
      • toDouble

        public static double toDouble​(long aLongValue,
                                      double aMinDouble,
                                      double aMaxDouble)
        Converts the given long value to a double of the given range.
        Parameters:
        aLongValue - The integer value which to convert accordingly
        aMinDouble - The lower bounds of the double value.
        aMaxDouble - The upper bounds of the double value.
        Returns:
        The accordingly converted value.
      • toHashCode

        public static int toHashCode​(String aValue)
        Calculates a Java-Version's implementation independent Hash-Code.
        Parameters:
        aValue - The String from which to get the Hash-Code.
        Returns:
        The according Hash-Code.
      • toHashCodes

        public static int[] toHashCodes​(String aSource,
                                        int aCount)
        Creates a given number of IDs from the provided source text. Useful when creating numbers from a pass-phrase.
        Parameters:
        aSource - The source text from which to generate the IDs.
        aCount - The number of IDs to generate.
        Returns:
        The IDs being generated.
      • toHashCodes

        public static int[] toHashCodes​(char[] aSource,
                                        int aCount)
        Creates a given number of IDs from the provided source text. Useful when creating numbers from a pass-phrase.
        Parameters:
        aSource - The source text from which to generate the IDs.
        aCount - The number of IDs to generate.
        Returns:
        The IDs being generated.