Class Number


  • public class Number
    extends java.lang.Object
    Number Utility
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int countBits​(int n)
      Counts the number of "1" bits in an unsigned 32-bit number.
      static boolean isInteger​(double num)
      Checks if a number is an integer.
      static boolean isNaN​(double num)
      Checks if a value is NaN.
      static int parseInt​(java.lang.String str, int radix)
      Parses a string into an integer.
      • Methods inherited from class java.lang.Object

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

      • isInteger

        public static boolean isInteger​(double num)
        Checks if a number is an integer.
        Parameters:
        num - The number to check.
        Returns:
        True if the number is an integer, false otherwise.
      • isNaN

        public static boolean isNaN​(double num)
        Checks if a value is NaN.
        Parameters:
        num - The value to check.
        Returns:
        True if the value is NaN, false otherwise.
      • parseInt

        public static int parseInt​(java.lang.String str,
                                   int radix)
        Parses a string into an integer.
        Parameters:
        str - The string to parse.
        radix - The radix to use (e.g., 10 for decimal, 16 for hexadecimal).
        Returns:
        The parsed integer.
      • countBits

        public static int countBits​(int n)
        Counts the number of "1" bits in an unsigned 32-bit number. This uses Brian Kernighan's algorithm.
        Parameters:
        n - The number to count bits in.
        Returns:
        The number of "1" bits.