Class DigitTools

java.lang.Object
com.github.yellowstonegames.core.DigitTools

public final class DigitTools extends Object
Utility class for converting to and from numbers and their String representations; this is mostly wrappers around Base for compatibility. New code should generally prefer using one of the predefined Base constants in that class, since you can control whether you want signed or unsigned output using the Base API. This class only produces unsigned output from its wrapper methods.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T extends CharSequence & Appendable>
    T
    appendHex(T builder, byte number)
     
    static <T extends CharSequence & Appendable>
    T
    appendHex(T builder, char number)
     
    static <T extends CharSequence & Appendable>
    T
    appendHex(T builder, double number)
     
    static <T extends CharSequence & Appendable>
    T
    appendHex(T builder, float number)
     
    static <T extends CharSequence & Appendable>
    T
    appendHex(T builder, int number)
     
    static <T extends CharSequence & Appendable>
    T
    appendHex(T builder, long number)
     
    static <T extends CharSequence & Appendable>
    T
    appendHex(T builder, short number)
     
    static <T extends CharSequence & Appendable>
    T
    appendJoinedFloatsBits(T sb, CharSequence delimiter, float... elements)
    Joins an array or varargs of floats into an Appendable CharSequence, separated by delimiter.
    static String
    bin(byte number)
     
    static String
    bin(char number)
     
    static String
    bin(double number)
     
    static String
    bin(float number)
     
    static String
    bin(int number)
     
    static String
    bin(long number)
     
    static String
    bin(short number)
     
    static String
    hex(byte number)
     
    static String
    hex(byte[] numbers)
     
    static String
    hex(char number)
     
    static String
    hex(char[] numbers)
     
    static String
    hex(double number)
     
    static String
    hex(double[] numbers)
     
    static String
    hex(float number)
     
    static String
    hex(float[] numbers)
     
    static String
    hex(int number)
     
    static String
    hex(int[] numbers)
     
    static String
    hex(long number)
     
    static String
    hex(long[] numbers)
     
    static String
    hex(short number)
     
    static String
    hex(short[] numbers)
     
    static String
    hexHash(boolean... array)
    Hashes array using Hasher and converts that hash to a hexadecimal String.
    static String
    hexHash(byte... array)
    Hashes array using Hasher and converts that hash to a hexadecimal String.
    static String
    hexHash(char... array)
    Hashes array using Hasher and converts that hash to a hexadecimal String.
    static String
    hexHash(double... array)
    Hashes array using Hasher and converts that hash to a hexadecimal String.
    static String
    hexHash(float... array)
    Hashes array using Hasher and converts that hash to a hexadecimal String.
    static String
    hexHash(int... array)
    Hashes array using Hasher and converts that hash to a hexadecimal String.
    static String
    hexHash(long... array)
    Hashes array using Hasher and converts that hash to a hexadecimal String.
    static String
    hexHash(short... array)
    Hashes array using Hasher and converts that hash to a hexadecimal String.
    static int
    Reads in a CharSequence containing only binary digits (only 0 and 1) and returns the int they represent, reading at most 32 characters and returning the result if valid or 0 otherwise.
    static int
    intFromBin(CharSequence cs, int start, int end)
    Reads in a CharSequence containing only binary digits (only 0 and 1) and returns the int they represent, reading at most 32 characters and returning the result if valid or 0 otherwise.
    static int
    Reads in a CharSequence containing only decimal digits (0-9) with an optional sign at the start and returns the int they represent, reading at most 10 characters (11 if there is a sign) and returning the result if valid, or 0 if nothing could be read.
    static int
    intFromDec(CharSequence cs, int start, int end)
    Reads in a CharSequence containing only decimal digits (0-9) with an optional sign at the start and returns the int they represent, reading at most 10 characters (11 if there is a sign) and returning the result if valid, or 0 if nothing could be read.
    static int
    intFromHex(char[] cs, int start, int end)
    Reads in a char[] containing only hex digits (only 0-9, a-f, and A-F) with an optional sign at the start and returns the int they represent, reading at most 8 characters (9 if there is a sign) and returning the result if valid, or 0 if nothing could be read.
    static int
    Reads in a CharSequence containing only hex digits (only 0-9, a-f, and A-F) with an optional sign at the start and returns the int they represent, reading at most 8 characters (9 if there is a sign) and returning the result if valid, or 0 if nothing could be read.
    static int
    intFromHex(CharSequence cs, int start, int end)
    Reads in a CharSequence containing only hex digits (only 0-9, a-f, and A-F) with an optional sign at the start and returns the int they represent, reading at most 8 characters (9 if there is a sign) and returning the result if valid, or 0 if nothing could be read.
    static String
    joinFloatsBits(CharSequence delimiter, float... elements)
    Joins an array or varargs of floats into a String, separated by delimiter.
    static long
    Reads in a CharSequence containing only binary digits (only 0 and 1) and returns the long they represent, reading at most 64 characters and returning the result if valid or 0 otherwise.
    static long
    longFromBin(CharSequence cs, int start, int end)
    Reads in a CharSequence containing only binary digits (only 0 and 1) and returns the long they represent, reading at most 64 characters and returning the result if valid or 0 otherwise.
    static long
    Reads in a CharSequence containing only decimal digits (0-9) with an optional sign at the start and returns the long they represent, reading at most 19 characters (20 if there is a sign) and returning the result if valid, or 0 if nothing could be read.
    static long
    longFromDec(CharSequence cs, int start, int end)
    Reads in a CharSequence containing only decimal digits (0-9) with an optional sign at the start and returns the long they represent between the given positions start and end, reading at most 19 characters (20 if there is a sign) or until end is reached and returning the result if valid, or 0 if nothing could be read.
    static long
    longFromHex(char[] cs, int start, int end)
    Reads in a char[] containing only hex digits (only 0-9, a-f, and A-F) with an optional sign at the start and returns the long they represent, reading at most 16 characters (17 if there is a sign) and returning the result if valid, or 0 if nothing could be read.
    static long
    Reads in a CharSequence containing only hex digits (only 0-9, a-f, and A-F) with an optional sign at the start and returns the long they represent, reading at most 16 characters (17 if there is a sign) and returning the result if valid, or 0 if nothing could be read.
    static long
    longFromHex(CharSequence cs, int start, int end)
    Reads in a CharSequence containing only hex digits (only 0-9, a-f, and A-F) with an optional sign at the start and returns the long they represent, reading at most 16 characters (17 if there is a sign) and returning the result if valid, or 0 if nothing could be read.
    static float[]
    splitFloatFromBits(String source, String delimiter)
    Given a String containing decimal (seeming nonsense) numbers separated by delimiter (which is permitted to be present at the end or absent), this parses the numbers into a float array.
    static int[]
    splitIntFromDec(String source, String delimiter)
    Given a String containing decimal numbers separated by delimiter (which is permitted to be present at the end or absent), this parses the numbers into an int array.
    static long[]
    splitLongFromDec(String source, String delimiter)
    Given a String containing decimal numbers separated by delimiter (which is permitted to be present at the end or absent), this parses the numbers into a long array.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • hex

      public static String hex(long number)
    • hex

      public static String hex(double number)
    • hex

      public static String hex(int number)
    • hex

      public static String hex(float number)
    • hex

      public static String hex(short number)
    • hex

      public static String hex(char number)
    • hex

      public static String hex(byte number)
    • appendHex

      public static <T extends CharSequence & Appendable> T appendHex(T builder, long number)
    • appendHex

      public static <T extends CharSequence & Appendable> T appendHex(T builder, double number)
    • appendHex

      public static <T extends CharSequence & Appendable> T appendHex(T builder, int number)
    • appendHex

      public static <T extends CharSequence & Appendable> T appendHex(T builder, float number)
    • appendHex

      public static <T extends CharSequence & Appendable> T appendHex(T builder, short number)
    • appendHex

      public static <T extends CharSequence & Appendable> T appendHex(T builder, char number)
    • appendHex

      public static <T extends CharSequence & Appendable> T appendHex(T builder, byte number)
    • hex

      public static String hex(long[] numbers)
    • hex

      public static String hex(double[] numbers)
    • hex

      public static String hex(int[] numbers)
    • hex

      public static String hex(float[] numbers)
    • hex

      public static String hex(short[] numbers)
    • hex

      public static String hex(char[] numbers)
    • hex

      public static String hex(byte[] numbers)
    • bin

      public static String bin(long number)
    • bin

      public static String bin(int number)
    • bin

      public static String bin(double number)
    • bin

      public static String bin(float number)
    • bin

      public static String bin(short number)
    • bin

      public static String bin(char number)
    • bin

      public static String bin(byte number)
    • longFromHex

      public static long longFromHex(CharSequence cs)
      Reads in a CharSequence containing only hex digits (only 0-9, a-f, and A-F) with an optional sign at the start and returns the long they represent, reading at most 16 characters (17 if there is a sign) and returning the result if valid, or 0 if nothing could be read. The leading sign can be '+' or '-' if present. This can also represent negative numbers as they are printed by such methods as String.format given a %x in the formatting string, or this class' hex(long) method; that is, if the first char of a 16-char (or longer) CharSequence is a hex digit 8 or higher, then the whole number represents a negative number, using two's complement and so on. This means "FFFFFFFFFFFFFFFF" would return the long -1 when passed to this, though you could also simply use "-1 ".
      Should be fairly close to Java 8's Long.parseUnsignedLong method, which is an odd omission from earlier JDKs. This doesn't throw on invalid input, though, instead returning 0 if the first char is not a hex digit, or stopping the parse process early if a non-hex-digit char is read before the end of cs is reached. If the parse is stopped early, this behaves as you would expect for a number with less digits, and simply doesn't fill the larger places.
      This is simply a wrapper around Base.readLong(CharSequence, int, int).
      Parameters:
      cs - a CharSequence, such as a String, containing only hex digits with an optional sign (no 0x at the start)
      Returns:
      the long that cs represents
    • longFromHex

      public static long longFromHex(CharSequence cs, int start, int end)
      Reads in a CharSequence containing only hex digits (only 0-9, a-f, and A-F) with an optional sign at the start and returns the long they represent, reading at most 16 characters (17 if there is a sign) and returning the result if valid, or 0 if nothing could be read. The leading sign can be '+' or '-' if present. This can also represent negative numbers as they are printed by such methods as String.format given a %x in the formatting string, or this class' hex(long) method; that is, if the first char of a 16-char (or longer) CharSequence is a hex digit 8 or higher, then the whole number represents a negative number, using two's complement and so on. This means "FFFFFFFFFFFFFFFF" would return the long -1 when passed to this, though you could also simply use "-1 ". If you use both '-' at the start and have the most significant digit as 8 or higher, such as with "-FFFFFFFFFFFFFFFF", then both indicate a negative number, but the digits will be processed first (producing -1) and then the whole thing will be multiplied by -1 to flip the sign again (returning 1).
      Should be fairly close to Java 8's Long.parseUnsignedLong method, which is an odd omission from earlier JDKs. This doesn't throw on invalid input, though, instead returning 0 if the first char is not a hex digit, or stopping the parse process early if a non-hex-digit char is read before end is reached. If the parse is stopped early, this behaves as you would expect for a number with less digits, and simply doesn't fill the larger places.
      This is simply a wrapper around Base.readLong(CharSequence, int, int).
      Parameters:
      cs - a CharSequence, such as a String, containing only hex digits with an optional sign (no 0x at the start)
      start - the (inclusive) first character position in cs to read
      end - the (exclusive) last character position in cs to read (this stops after 16 characters if end is too large)
      Returns:
      the long that cs represents
    • longFromHex

      public static long longFromHex(char[] cs, int start, int end)
      Reads in a char[] containing only hex digits (only 0-9, a-f, and A-F) with an optional sign at the start and returns the long they represent, reading at most 16 characters (17 if there is a sign) and returning the result if valid, or 0 if nothing could be read. The leading sign can be '+' or '-' if present. This can also represent negative numbers as they are printed by such methods as String.format given a %x in the formatting string, or this class' hex(long) method; that is, if the first digit of a 16-char (or longer) char[] is a hex digit 8 or higher, then the whole number represents a negative number, using two's complement and so on. This means "FFFFFFFFFFFFFFFF" would return the long -1L when passed to this, though you could also simply use "-1 ". If you use both '-' at the start and have the most significant digit as 8 or higher, such as with "-FFFFFFFFFFFFFFFF", then both indicate a negative number, but the digits will be processed first (producing -1) and then the whole thing will be multiplied by -1 to flip the sign again (returning 1).
      Should be fairly close to Java 8's Long.parseUnsignedLong method, which is an odd omission from earlier JDKs. This doesn't throw on invalid input, though, instead returning 0 if the first char is not a hex digit, or stopping the parse process early if a non-hex-digit char is read before end is reached. If the parse is stopped early, this behaves as you would expect for a number with less digits, and simply doesn't fill the larger places.
      Parameters:
      cs - a char array containing only hex digits with an optional sign (no 0x at the start)
      start - the (inclusive) first character position in cs to read
      end - the (exclusive) last character position in cs to read (this stops after 8 or 9 characters if end is too large, depending on sign)
      Returns:
      the long that cs represents
    • intFromHex

      public static int intFromHex(CharSequence cs)
      Reads in a CharSequence containing only hex digits (only 0-9, a-f, and A-F) with an optional sign at the start and returns the int they represent, reading at most 8 characters (9 if there is a sign) and returning the result if valid, or 0 if nothing could be read. The leading sign can be '+' or '-' if present. This can also represent negative numbers as they are printed by such methods as String.format given a %x in the formatting string, or this class' hex(int) method; that is, if the first digit of an 8-char (or longer) CharSequence is a hex digit 8 or higher, then the whole number represents a negative number, using two's complement and so on. This means "FFFFFFFF" would return the int -1 when passed to this, though you could also simply use "-1 ". If you use both '-' at the start and have the most significant digit as 8 or higher, such as with "-FFFFFFFF", then both indicate a negative number, but the digits will be processed first (producing -1) and then the whole thing will be multiplied by -1 to flip the sign again (returning 1).
      Should be fairly close to Java 8's Integer.parseUnsignedInt method, which is an odd omission from earlier JDKs. This doesn't throw on invalid input, though, instead returning 0 if the first char is not a hex digit, or stopping the parse process early if a non-hex-digit char is read before the end of cs is reached. If the parse is stopped early, this behaves as you would expect for a number with less digits, and simply doesn't fill the larger places.
      Parameters:
      cs - a CharSequence, such as a String, containing only hex digits with an optional sign (no 0x at the start)
      Returns:
      the int that cs represents
    • intFromHex

      public static int intFromHex(CharSequence cs, int start, int end)
      Reads in a CharSequence containing only hex digits (only 0-9, a-f, and A-F) with an optional sign at the start and returns the int they represent, reading at most 8 characters (9 if there is a sign) and returning the result if valid, or 0 if nothing could be read. The leading sign can be '+' or '-' if present. This can also represent negative numbers as they are printed by such methods as String.format given a %x in the formatting string, or this class' hex(int) method; that is, if the first digit of an 8-char (or longer) CharSequence is a hex digit 8 or higher, then the whole number represents a negative number, using two's complement and so on. This means "FFFFFFFF" would return the int -1 when passed to this, though you could also simply use "-1 ". If you use both '-' at the start and have the most significant digit as 8 or higher, such as with "-FFFFFFFF", then both indicate a negative number, but the digits will be processed first (producing -1) and then the whole thing will be multiplied by -1 to flip the sign again (returning 1).
      Should be fairly close to Java 8's Integer.parseUnsignedInt method, which is an odd omission from earlier JDKs. This doesn't throw on invalid input, though, instead returning 0 if the first char is not a hex digit, or stopping the parse process early if a non-hex-digit char is read before end is reached. If the parse is stopped early, this behaves as you would expect for a number with less digits, and simply doesn't fill the larger places.
      Parameters:
      cs - a CharSequence, such as a String, containing only hex digits with an optional sign (no 0x at the start)
      start - the (inclusive) first character position in cs to read
      end - the (exclusive) last character position in cs to read (this stops after 8 or 9 characters if end is too large, depending on sign)
      Returns:
      the int that cs represents
    • intFromHex

      public static int intFromHex(char[] cs, int start, int end)
      Reads in a char[] containing only hex digits (only 0-9, a-f, and A-F) with an optional sign at the start and returns the int they represent, reading at most 8 characters (9 if there is a sign) and returning the result if valid, or 0 if nothing could be read. The leading sign can be '+' or '-' if present. This can also represent negative numbers as they are printed by such methods as String.format given a %x in the formatting string, or this class' hex(int) method; that is, if the first digit of an 8-char (or longer) char[] is a hex digit 8 or higher, then the whole number represents a negative number, using two's complement and so on. This means "FFFFFFFF" would return the int -1 when passed to this, though you could also simply use "-1 ". If you use both '-' at the start and have the most significant digit as 8 or higher, such as with "-FFFFFFFF", then both indicate a negative number, but the digits will be processed first (producing -1) and then the whole thing will be multiplied by -1 to flip the sign again (returning 1).
      Should be fairly close to Java 8's Integer.parseUnsignedInt method, which is an odd omission from earlier JDKs. This doesn't throw on invalid input, though, instead returning 0 if the first char is not a hex digit, or stopping the parse process early if a non-hex-digit char is read before end is reached. If the parse is stopped early, this behaves as you would expect for a number with less digits, and simply doesn't fill the larger places.
      Parameters:
      cs - a char array containing only hex digits with an optional sign (no 0x at the start)
      start - the (inclusive) first character position in cs to read
      end - the (exclusive) last character position in cs to read (this stops after 8 or 9 characters if end is too large, depending on sign)
      Returns:
      the int that cs represents
    • longFromDec

      public static long longFromDec(CharSequence cs)
      Reads in a CharSequence containing only decimal digits (0-9) with an optional sign at the start and returns the long they represent, reading at most 19 characters (20 if there is a sign) and returning the result if valid, or 0 if nothing could be read. The leading sign can be '+' or '-' if present. Unlike intFromDec(CharSequence), this can't effectively be used to read unsigned longs as decimal literals, since anything larger than the highest signed long would be larger than the normal limit for longs as text (it would be 20 characters without a sign, where we limit it to 19 without a sign to match normal behavior).
      Should be fairly close to the JDK's Long.parseLong method, but this also supports CharSequence data instead of just String data, and ignores chars after the number. This doesn't throw on invalid input, either, instead returning 0 if the first char is not a decimal digit, or stopping the parse process early if a non-decimal-digit char is read before the end of cs is reached. If the parse is stopped early, this behaves as you would expect for a number with less digits, and simply doesn't fill the larger places.
      Parameters:
      cs - a CharSequence, such as a String, containing only digits 0-9 with an optional sign
      Returns:
      the long that cs represents
    • longFromDec

      public static long longFromDec(CharSequence cs, int start, int end)
      Reads in a CharSequence containing only decimal digits (0-9) with an optional sign at the start and returns the long they represent between the given positions start and end, reading at most 19 characters (20 if there is a sign) or until end is reached and returning the result if valid, or 0 if nothing could be read. The leading sign can be '+' or '-' if present. Unlike intFromDec(CharSequence, int, int), this can't effectively be used to read unsigned longs as decimal literals, since anything larger than the highest signed long would be larger than the normal limit for longs as text (it would be 20 characters without a sign, where we limit it to 19 without a sign to match normal behavior).
      Should be fairly close to the JDK's Long.parseLong method, but this also supports CharSequence data instead of just String data, and allows specifying a start and end. This doesn't throw on invalid input, either, instead returning 0 if the first char is not a decimal digit, or stopping the parse process early if a non-decimal-digit char is read before end is reached. If the parse is stopped early, this behaves as you would expect for a number with less digits, and simply doesn't fill the larger places.
      Parameters:
      cs - a CharSequence, such as a String, containing only digits 0-9 with an optional sign
      start - the (inclusive) first character position in cs to read
      end - the (exclusive) last character position in cs to read (this stops after 19 or 20 characters if end is too large, depending on sign)
      Returns:
      the long that cs represents
    • intFromDec

      public static int intFromDec(CharSequence cs)
      Reads in a CharSequence containing only decimal digits (0-9) with an optional sign at the start and returns the int they represent, reading at most 10 characters (11 if there is a sign) and returning the result if valid, or 0 if nothing could be read. The leading sign can be '+' or '-' if present. This can technically be used to handle unsigned integers in decimal format, but it isn't the intended purpose. If you do use it for handling unsigned ints, 2147483647 is normally the highest positive int and -2147483648 the lowest negative one, but if you give this a number between 2147483647 and 2147483647 + 2147483648, it will interpret it as a negative number that fits in bounds using the normal rules for converting between signed and unsigned numbers.
      Should be fairly close to the JDK's Integer.parseInt method, but this also supports CharSequence data instead of just String data, and ignores chars after the number. This doesn't throw on invalid input, either, instead returning 0 if the first char is not a decimal digit, or stopping the parse process early if a non-decimal-digit char is read before the end of cs is reached. If the parse is stopped early, this behaves as you would expect for a number with less digits, and simply doesn't fill the larger places.
      Parameters:
      cs - a CharSequence, such as a String, containing only digits 0-9 with an optional sign
      Returns:
      the int that cs represents
    • intFromDec

      public static int intFromDec(CharSequence cs, int start, int end)
      Reads in a CharSequence containing only decimal digits (0-9) with an optional sign at the start and returns the int they represent, reading at most 10 characters (11 if there is a sign) and returning the result if valid, or 0 if nothing could be read. The leading sign can be '+' or '-' if present. This can technically be used to handle unsigned integers in decimal format, but it isn't the intended purpose. If you do use it for handling unsigned ints, 2147483647 is normally the highest positive int and -2147483648 the lowest negative one, but if you give this a number between 2147483647 and 2147483647 + 2147483648, it will interpret it as a negative number that fits in bounds using the normal rules for converting between signed and unsigned numbers.
      Should be fairly close to the JDK's Integer.parseInt method, but this also supports CharSequence data instead of just String data, and allows specifying a start and end. This doesn't throw on invalid input, either, instead returning 0 if the first char is not a decimal digit, or stopping the parse process early if a non-decimal-digit char is read before end is reached. If the parse is stopped early, this behaves as you would expect for a number with less digits, and simply doesn't fill the larger places.
      Parameters:
      cs - a CharSequence, such as a String, containing only digits 0-9 with an optional sign
      start - the (inclusive) first character position in cs to read
      end - the (exclusive) last character position in cs to read (this stops after 10 or 11 characters if end is too large, depending on sign)
      Returns:
      the int that cs represents
    • longFromBin

      public static long longFromBin(CharSequence cs)
      Reads in a CharSequence containing only binary digits (only 0 and 1) and returns the long they represent, reading at most 64 characters and returning the result if valid or 0 otherwise. The first digit is considered the sign bit iff cs is 64 chars long.
      Should be fairly close to Java 8's Long.parseUnsignedLong method, which is a bizarre omission from earlier JDKs. This doesn't throw on invalid input, though, instead returning 0.
      Parameters:
      cs - a CharSequence, such as a String, containing only binary digits (nothing at the start)
      Returns:
      the long that cs represents
    • longFromBin

      public static long longFromBin(CharSequence cs, int start, int end)
      Reads in a CharSequence containing only binary digits (only 0 and 1) and returns the long they represent, reading at most 64 characters and returning the result if valid or 0 otherwise. The first digit is considered the sign bit iff cs is 64 chars long.
      Should be fairly close to Java 8's Long.parseUnsignedLong method, which is a bizarre omission from earlier JDKs. This doesn't throw on invalid input, though, instead returning 0.
      Parameters:
      cs - a CharSequence, such as a String, containing only binary digits (nothing at the start)
      start - the first character position in cs to read from
      end - the last character position in cs to read from (this stops after 64 characters if end is too large)
      Returns:
      the long that cs represents
    • intFromBin

      public static int intFromBin(CharSequence cs)
      Reads in a CharSequence containing only binary digits (only 0 and 1) and returns the int they represent, reading at most 32 characters and returning the result if valid or 0 otherwise. The first digit is considered the sign bit iff cs is 32 chars long.
      Should be fairly close to Java 8's Integer.parseUnsignedInt method, which is a bizarre omission from earlier JDKs. This doesn't throw on invalid input, though, instead returning 0.
      Parameters:
      cs - a CharSequence, such as a String, containing only binary digits (nothing at the start)
      Returns:
      the int that cs represents
    • intFromBin

      public static int intFromBin(CharSequence cs, int start, int end)
      Reads in a CharSequence containing only binary digits (only 0 and 1) and returns the int they represent, reading at most 32 characters and returning the result if valid or 0 otherwise. The first digit is considered the sign bit iff cs is 32 chars long.
      Should be fairly close to Java 8's Integer.parseUnsignedInt method, which is a bizarre omission from earlier JDKs. This doesn't throw on invalid input, though, instead returning 0.
      Parameters:
      cs - a CharSequence, such as a String, containing only binary digits (nothing at the start)
      start - the first character position in cs to read from
      end - the last character position in cs to read from (this stops after 32 characters if end is too large)
      Returns:
      the int that cs represents
    • hexHash

      public static String hexHash(boolean... array)
      Hashes array using Hasher and converts that hash to a hexadecimal String.
      Parameters:
      array - a non-null, non-empty boolean array
      Returns:
      the 16-hex-digit representation of array's hash as a hexadecimal number
    • hexHash

      public static String hexHash(byte... array)
      Hashes array using Hasher and converts that hash to a hexadecimal String.
      Parameters:
      array - a non-null, non-empty byte array
      Returns:
      the 16-hex-digit representation of array's hash as a hexadecimal number
    • hexHash

      public static String hexHash(short... array)
      Hashes array using Hasher and converts that hash to a hexadecimal String.
      Parameters:
      array - a non-null, non-empty short array
      Returns:
      the 16-hex-digit representation of array's hash as a hexadecimal number
    • hexHash

      public static String hexHash(char... array)
      Hashes array using Hasher and converts that hash to a hexadecimal String.
      Parameters:
      array - a non-null, non-empty char array
      Returns:
      the 16-hex-digit representation of array's hash as a hexadecimal number
    • hexHash

      public static String hexHash(int... array)
      Hashes array using Hasher and converts that hash to a hexadecimal String.
      Parameters:
      array - a non-null, non-empty int array
      Returns:
      the 16-hex-digit representation of array's hash as a hexadecimal number
    • hexHash

      public static String hexHash(long... array)
      Hashes array using Hasher and converts that hash to a hexadecimal String.
      Parameters:
      array - a non-null, non-empty long array
      Returns:
      the 16-hex-digit representation of array's hash as a hexadecimal number
    • hexHash

      public static String hexHash(float... array)
      Hashes array using Hasher and converts that hash to a hexadecimal String.
      Parameters:
      array - a non-null, non-empty float array
      Returns:
      the 16-hex-digit representation of array's hash as a hexadecimal number
    • hexHash

      public static String hexHash(double... array)
      Hashes array using Hasher and converts that hash to a hexadecimal String.
      Parameters:
      array - a non-null, non-empty double array
      Returns:
      the 16-hex-digit representation of array's hash as a hexadecimal number
    • splitLongFromDec

      public static long[] splitLongFromDec(String source, String delimiter)
      Given a String containing decimal numbers separated by delimiter (which is permitted to be present at the end or absent), this parses the numbers into a long array. The source is commonly generated by Base.join(CharSequence, long[]).
      Parameters:
      source - a String containing decimal numbers separated by delimiter
      delimiter - a non-null, non-empty String that separates numbers in the source
      Returns:
      a long array containing the numbers found in source
    • splitIntFromDec

      public static int[] splitIntFromDec(String source, String delimiter)
      Given a String containing decimal numbers separated by delimiter (which is permitted to be present at the end or absent), this parses the numbers into an int array. The source is commonly generated by Base.join(CharSequence, int[]).
      Parameters:
      source - a String containing decimal numbers separated by delimiter
      delimiter - a non-null, non-empty String that separates numbers in the source
      Returns:
      an int array containing the numbers found in source
    • joinFloatsBits

      public static String joinFloatsBits(CharSequence delimiter, float... elements)
      Joins an array or varargs of floats into a String, separated by delimiter. This does not write the floats conventionally; instead it converts them to their int bits and reverses the bytes of that int before appending it to the String. This means the float 0.0f is written as 0, most small powers of 2 are 3 or 4 digits, and the longest numbers have the very least-significant bits set. This is meant to be decoded by splitFloatFromBits(String, String). The output is not human-readable, and uses Base.SIMPLE64.
      Parameters:
      delimiter - what separates the encoded float elements
      elements - an array or varargs of float to encode
      Returns:
      a String that holds the encoded floats
    • appendJoinedFloatsBits

      public static <T extends CharSequence & Appendable> T appendJoinedFloatsBits(T sb, CharSequence delimiter, float... elements)
      Joins an array or varargs of floats into an Appendable CharSequence, separated by delimiter. This does not write the floats conventionally; instead it converts them to their int bits and reverses the bytes of that int before appending it to the Appendable. This means the float 0.0f is written as 0, most small powers of 2 are 3 or 4 digits, and the longest numbers have the very least-significant bits set. This is meant to be decoded by splitFloatFromBits(String, String). The output is not human-readable, and uses Base.SIMPLE64.
      Type Parameters:
      T - must implement both CharSequence and Appendable; commonly StringBuilder or CharList
      Parameters:
      sb - any object that implements both CharSequence and Appendable, such as StringBuilder or CharList
      delimiter - what separates the encoded float elements
      elements - an array or varargs of float to encode
      Returns:
      sb, potentially after changes
    • splitFloatFromBits

      public static float[] splitFloatFromBits(String source, String delimiter)
      Given a String containing decimal (seeming nonsense) numbers separated by delimiter (which is permitted to be present at the end or absent), this parses the numbers into a float array. The source is commonly generated by joinFloatsBits(CharSequence, float...). The output is not human-readable, and uses Base.SIMPLE64.
      Parameters:
      source - a String containing decimal numbers separated by delimiter
      delimiter - a non-null, non-empty String that separates numbers in the source
      Returns:
      a float array containing the numbers found in source