Class NumberUtil

java.lang.Object
org.seppiko.commons.utils.NumberUtil

public class NumberUtil extends Object
Number Util
Author:
Leonard Woo
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Fullwidth digits ('0' through '9')
    static final int
    ISO-LATIN-1(ASCII) digits ('0' through '9')
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    between(byte num, byte min, byte max)
    test num between min and max
    static boolean
    between(char num, char min, char max)
    test num between min and max
    static boolean
    between(double num, double min, double max)
    test num between min and max
    static boolean
    between(float num, float min, float max)
    test num between min and max
    static boolean
    between(int num, int min, int max)
    test num between min and max
    static boolean
    between(long num, long min, long max)
    test num between min and max
    static boolean
    between(short num, short min, short max)
    test num between min and max
    static boolean
    test num between min and max
    static boolean
    test num between min and max
    static String
    convert(CharSequence input, int outType)
    Convert between LATIN_DIGITS and FULLWIDTH_DIGITS and support calculation result.
    static String
    format(String precisionPattern, double number)
    Double format
    static int[]
    toUnsignedIntArray(byte[] src)
    byte array to unsigned int array
    static long[]
    int array to unsigned long array
    static int[]
    toUnsignedShortArray(short[] src)
    short array to unsigned int array

    Methods inherited from class java.lang.Object

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

    • LATIN_DIGITS

      public static final int LATIN_DIGITS
      ISO-LATIN-1(ASCII) digits ('0' through '9')
      See Also:
    • FULLWIDTH_DIGITS

      public static final int FULLWIDTH_DIGITS
      Fullwidth digits ('0' through '9')
      See Also:
  • Constructor Details

    • NumberUtil

      public NumberUtil()
  • Method Details

    • between

      public static boolean between(byte num, byte min, byte max)
      test num between min and max
      Parameters:
      num - number
      min - minimum number
      max - maximum number
      Returns:
      true number is between the maximum and minimum
    • between

      public static boolean between(short num, short min, short max)
      test num between min and max
      Parameters:
      num - number
      min - minimum number
      max - maximum number
      Returns:
      true number is between the maximum and minimum
    • between

      public static boolean between(int num, int min, int max)
      test num between min and max
      Parameters:
      num - number
      min - minimum number
      max - maximum number
      Returns:
      true number is between the maximum and minimum
    • between

      public static boolean between(long num, long min, long max)
      test num between min and max
      Parameters:
      num - number
      min - minimum number
      max - maximum number
      Returns:
      true number is between the maximum and minimum
    • between

      public static boolean between(float num, float min, float max)
      test num between min and max
      Parameters:
      num - number
      min - minimum number
      max - maximum number
      Returns:
      true number is between the maximum and minimum
    • between

      public static boolean between(double num, double min, double max)
      test num between min and max
      Parameters:
      num - number
      min - minimum number
      max - maximum number
      Returns:
      true number is between the maximum and minimum
    • between

      public static boolean between(char num, char min, char max)
      test num between min and max
      Parameters:
      num - number
      min - minimum number
      max - maximum number
      Returns:
      true number is between the maximum and minimum
    • between

      public static boolean between(BigDecimal num, BigDecimal min, BigDecimal max)
      test num between min and max
      Parameters:
      num - number
      min - minimum number
      max - maximum number
      Returns:
      true number is between the maximum and minimum
    • between

      public static boolean between(BigInteger num, BigInteger min, BigInteger max)
      test num between min and max
      Parameters:
      num - number
      min - minimum number
      max - maximum number
      Returns:
      true number is between the maximum and minimum
    • format

      public static String format(String precisionPattern, double number)
      Double format
      Parameters:
      precisionPattern - precision pattern, e.g. 0.00
      number - double number
      Returns:
      formatted string
    • toUnsignedIntArray

      public static int[] toUnsignedIntArray(byte[] src)
      byte array to unsigned int array
      Parameters:
      src - byte array
      Returns:
      unsigned int array
    • toUnsignedShortArray

      public static int[] toUnsignedShortArray(short[] src)
      short array to unsigned int array
      Parameters:
      src - short array
      Returns:
      unsigned int array
    • toUnsignedLongArray

      public static long[] toUnsignedLongArray(int[] src)
      int array to unsigned long array
      Parameters:
      src - int array
      Returns:
      unsigned long array
    • convert

      public static String convert(CharSequence input, int outType) throws IllegalArgumentException
      Convert between LATIN_DIGITS and FULLWIDTH_DIGITS and support calculation result.
      Parameters:
      input - digit character sequence
      outType - output digit type NumberUtil.LATIN_DIGITS or NumberUtil.FULLWIDTH_DIGITS
      Returns:
      digit string
      Throws:
      IllegalArgumentException - input is not digit or outType is wrong