Package: org.codehaus.groovy.syntax

## [Java] Class Numbers

- org.codehaus.groovy.syntax.Numbers

-     public class Numbers
      extends Object

  Utility class for processing and parsing Groovy numeric literals. Provides methods for character classification (digits, hex digits, etc.) and conversion of numeric literal strings to appropriate Number objects, handling various bases (decimal, octal, hexadecimal, binary) and type suffixes.

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static boolean` | `isDigit(char c)` Returns `true` if the specified character is a decimal digit (0-9).
    `` | `public static boolean` | `isHexDigit(char c)` Returns `true` if the specified character is a hexadecimal digit (0-9, A-F, a-f).
    `` | `public static boolean` | `isNumericTypeSpecifier(char c, boolean isDecimal)` Returns `true` if the specified character is a valid type suffix for a numeric literal.
    `` | `public static boolean` | `isOctalDigit(char c)` Returns `true` if the specified character is an octal digit (0-7).
    `` | `public static Number` | `parseDecimal(String text)` Builds a Number from the given decimal descriptor.
    `` | `public static Number` | `parseInteger(String text)` Builds a Number from the given integer descriptor.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### public static boolean isDigit(char c)

      Returns `true` if the specified character is a decimal digit (0-9).

      Parameters:
        `c` - the character to check
      Returns:
        `true` if the character is a decimal digit

    - #### public static boolean isHexDigit(char c)

      Returns `true` if the specified character is a hexadecimal digit (0-9, A-F, a-f).

      Parameters:
        `c` - the character to check
      Returns:
        `true` if the character is a hexadecimal digit

    - #### public static boolean isNumericTypeSpecifier(char c, boolean isDecimal)

      Returns `true` if the specified character is a valid type suffix for a numeric literal. For decimal literals: G/g (BigDecimal), D/d (double), F/f (float). For integer literals: G/g (BigInteger), I/i (int), L/l (long).

      Parameters:
        `c` - the character to check
        `isDecimal` - `true` if checking a decimal literal suffix, `false` for integer
      Returns:
        `true` if the character is a valid numeric type specifier

    - #### public static boolean isOctalDigit(char c)

      Returns `true` if the specified character is an octal digit (0-7).

      Parameters:
        `c` - the character to check
      Returns:
        `true` if the character is an octal digit

    - #### public static Number parseDecimal(String text)

      Builds a Number from the given decimal descriptor. Uses BigDecimal, unless, Double or Float is requested.

      throws:
        NumberFormatException if the number does not fit within the type requested by the type specifier suffix (invalid numbers don't make it here)
      Parameters:
        `text` - literal text to parse
      Returns:
        instantiated Number object

    - #### public static Number parseInteger(String text)

      Builds a Number from the given integer descriptor. Creates the narrowest type possible, or a specific type, if specified.

      throws:
        NumberFormatException if the number does not fit within the type requested by the type specifier suffix (invalid numbers don't make it here)
      Parameters:
        `text` - literal text to parse
      Returns:
        instantiated Number object