com.smartgwt.client.util

## Class NumberUtil

- java.lang.Object
- - com.smartgwt.client.util.NumberUtil

-     public class NumberUtil
      extends java.lang.Object

  Static singleton class containing APIs for interacting with Numbers.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `NumberUtil()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `clamp(int number, int min, int max)` Returns a clamped number between a min and max.
    `static java.lang.String` | `format(double number, java.lang.String format)` Return the parameter number formatted according to the parameter `FormatString`.
    `static java.lang.String` | `format(java.lang.Double number, java.lang.String format)` Return the parameter number formatted according to the parameter `FormatString`.
    `static java.lang.String` | `format(float number, java.lang.String format)` Return the parameter number formatted according to the parameter `FormatString`.
    `static java.lang.String` | `format(java.lang.Float number, java.lang.String format)` Return the parameter number formatted according to the parameter `FormatString`.
    `static java.lang.String` | `format(java.lang.Integer number, java.lang.String format)` Return the parameter number formatted according to the parameter `FormatString`.
    `static java.lang.String` | `format(int number, java.lang.String format)` Return the parameter number formatted according to the parameter `FormatString`.
    `static java.lang.String` | `getCurrencySymbol()` The currency symbol to use when formatting numbers
    `static java.lang.String` | `getDecimalSymbol()` The decimal symbol to use when formatting numbers
    `static int` | `getGroupingFormat()` The grouping-format for numbers
    `static java.lang.String` | `getGroupingSymbol()` The grouping symbol, or thousands separator, to use when formatting numbers
    `static int` | `getNegativeFormat()` The format to use when formatting nagative numbers.
    `static java.lang.String` | `getNegativeSymbol()` The negative symbol to use when formatting numbers
    `static java.lang.Boolean` | `isBetween(int number)` Returns true if the number parameter falls between the 'first' and 'second' parameters.
    `static java.lang.Boolean` | `isBetween(int number, int first)`
    `static java.lang.Boolean` | `isBetween(int number, int first, int second)`
    `static java.lang.Boolean` | `isBetween(int number, int first, int second, int inclusive)` Returns true if the number parameter falls between the 'first' and 'second' parameters.
    `static void` | `setCurrencySymbol(java.lang.String currencySymbol)` The currency symbol to use when formatting numbers
    `static void` | `setDecimalSymbol(java.lang.String decimalSymbol)` The decimal symbol to use when formatting numbers
    `static void` | `setGroupingFormat(int groupingFormat)` The grouping-format for numbers
    `static void` | `setGroupingSymbol(java.lang.String groupingSymbol)` The grouping symbol, or thousands separator, to use when formatting numbers
    `static void` | `setNegativeFormat(int negativeFormat)` The format to use when formatting nagative numbers.
    `static void` | `setNegativeSymbol(java.lang.String negativeSymbol)` The negative symbol to use when formatting numbers

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### NumberUtil

          public NumberUtil()

  - ### Method Detail

    - #### setCurrencySymbol

          public static void setCurrencySymbol(java.lang.String currencySymbol)

      The currency symbol to use when formatting numbers

      Note: the correct symbol is normally auto-derived from GWT's locale system, so the only valid reason to set it is desiring to use a language from one locale in combination with formatting rules from another locale, in a single application and for a single end user.

      Parameters:
        `currencySymbol` - new currencySymbol. Default value is "$".

    - #### getCurrencySymbol

          public static java.lang.String getCurrencySymbol()

      The currency symbol to use when formatting numbers

      Note: the correct symbol is normally auto-derived from GWT's locale system, so the only valid reason to set it is desiring to use a language from one locale in combination with formatting rules from another locale, in a single application and for a single end user.

      Returns:
        current value of currencySymbol

    - #### setDecimalSymbol

          public static void setDecimalSymbol(java.lang.String decimalSymbol)

      The decimal symbol to use when formatting numbers

      Note: the correct symbol is normally auto-derived from GWT's locale system, so the only valid reason to set it is desiring to use a language from one locale in combination with formatting rules from another locale, in a single application and for a single end user.

      Parameters:
        `decimalSymbol` - new decimalSymbol. Default value is ".".

    - #### getDecimalSymbol

          public static java.lang.String getDecimalSymbol()

      The decimal symbol to use when formatting numbers

      Note: the correct symbol is normally auto-derived from GWT's locale system, so the only valid reason to set it is desiring to use a language from one locale in combination with formatting rules from another locale, in a single application and for a single end user.

      Returns:
        current value of decimalSymbol

    - #### setGroupingFormat

          public static void setGroupingFormat(int groupingFormat)

      The grouping-format for numbers

      Note: the correct format is normally auto-derived from GWT's locale system, so the only valid reason to set it is desiring to use a language from one locale in combination with formatting rules from another locale, in a single application and for a single end user.

      Parameters:
        `groupingFormat` - new groupingFormat. Default value is 1.

    - #### getGroupingFormat

          public static int getGroupingFormat()

      The grouping-format for numbers

      Note: the correct format is normally auto-derived from GWT's locale system, so the only valid reason to set it is desiring to use a language from one locale in combination with formatting rules from another locale, in a single application and for a single end user.

      Returns:
        current value of groupingFormat

    - #### setGroupingSymbol

          public static void setGroupingSymbol(java.lang.String groupingSymbol)

      The grouping symbol, or thousands separator, to use when formatting numbers

      Note: the correct symbol is normally auto-derived from GWT's locale system, so the only valid reason to set it is desiring to use a language from one locale in combination with formatting rules from another locale, in a single application and for a single end user.

      Parameters:
        `groupingSymbol` - new groupingSymbol. Default value is ",".

    - #### getGroupingSymbol

          public static java.lang.String getGroupingSymbol()

      The grouping symbol, or thousands separator, to use when formatting numbers

      Note: the correct symbol is normally auto-derived from GWT's locale system, so the only valid reason to set it is desiring to use a language from one locale in combination with formatting rules from another locale, in a single application and for a single end user.

      Returns:
        current value of groupingSymbol

    - #### setNegativeFormat

          public static void setNegativeFormat(int negativeFormat)

      The format to use when formatting nagative numbers. Supported values are: 1 = before, 2 = after, 3 = beforeSpace, 4 = afterSpace, 5 = parens

      Note: the correct format is normally auto-derived from GWT's locale system, so the only valid reason to set it is desiring to use a language from one locale in combination with formatting rules from another locale, in a single application and for a single end user.

      Parameters:
        `negativeFormat` - new negativeFormat. Default value is 1.

    - #### getNegativeFormat

          public static int getNegativeFormat()

      The format to use when formatting nagative numbers. Supported values are: 1 = before, 2 = after, 3 = beforeSpace, 4 = afterSpace, 5 = parens

      Note: the correct format is normally auto-derived from GWT's locale system, so the only valid reason to set it is desiring to use a language from one locale in combination with formatting rules from another locale, in a single application and for a single end user.

      Returns:
        current value of negativeFormat

    - #### setNegativeSymbol

          public static void setNegativeSymbol(java.lang.String negativeSymbol)

      The negative symbol to use when formatting numbers

      Note: the correct symbol is normally auto-derived from GWT's locale system, so the only valid reason to set it is desiring to use a language from one locale in combination with formatting rules from another locale, in a single application and for a single end user.

      Parameters:
        `negativeSymbol` - new negativeSymbol. Default value is "-".

    - #### getNegativeSymbol

          public static java.lang.String getNegativeSymbol()

      The negative symbol to use when formatting numbers

      Note: the correct symbol is normally auto-derived from GWT's locale system, so the only valid reason to set it is desiring to use a language from one locale in combination with formatting rules from another locale, in a single application and for a single end user.

      Returns:
        current value of negativeSymbol

    - #### clamp

          public static int clamp(int number,
                                  int min,
                                  int max)

      Returns a clamped number between a min and max.

            var clamped = isc.NumberUtil.clamp(10, 0, 5); // Returns 5 because 10 is greater than 5
            var clamped = isc.NumberUtil.clamp(-3, 0, 5); // Returns 0 because -3 is less than 0
            var clamped = isc.NumberUtil.clamp(4, 0, 5); // Returns 4 because 4 is between 0 and 5

      Parameters:
        `number` - the number to clamp
        `min` - the number to return if the number is lower than min
        `max` - the number to return if the number is higher than max
      Returns:
        the clamped number

    - #### isBetween

          public static java.lang.Boolean isBetween(int number)

      Returns true if the number parameter falls between the 'first' and 'second' parameters.
      Parameters:
        `number` - Number object to be evaluated
      Returns:
        True if the given `number` falls inside the given range, false otherwise @example n = 3; bool = n.isBetween(3, 3, 6, true); // true

    - #### isBetween

          public static java.lang.Boolean isBetween(int number,
                                                    int first)

      See Also:
        `isBetween(int)`

    - #### isBetween

          public static java.lang.Boolean isBetween(int number,
                                                    int first,
                                                    int second)

      See Also:
        `isBetween(int)`

    - #### isBetween

          public static java.lang.Boolean isBetween(int number,
                                                    int first,
                                                    int second,
                                                    int inclusive)

      Returns true if the number parameter falls between the 'first' and 'second' parameters.
      Parameters:
        `number` - Number object to be evaluated
        `first` - Number at the lower boundary
        `second` - Number at the upper boundary
        `inclusive` - Whether or not the numbers at either end of the boundary should be included in the comparison
      Returns:
        True if the given `number` falls inside the given range, false otherwise @example n = 3; bool = n.isBetween(3, 3, 6, true); // true

    - #### format

          public static java.lang.String format(int number,
                                                java.lang.String format)

      Return the parameter number formatted according to the parameter `FormatString`. This method is used to implement the `format` functionality, but it can also be used to format arbitrary numbers programmatically.
      Parameters:
        `number` - The number to format
        `format` - The format to apply. See `FormatString`
      Returns:
        formatted number string

    - #### format

          public static java.lang.String format(float number,
                                                java.lang.String format)

      Return the parameter number formatted according to the parameter `FormatString`. This method is used to implement the `format` functionality, but it can also be used to format arbitrary numbers programmatically.
      Parameters:
        `number` - The number to format
        `format` - The format to apply. See `FormatString`
      Returns:
        formatted number string

    - #### format

          public static java.lang.String format(double number,
                                                java.lang.String format)

      Return the parameter number formatted according to the parameter `FormatString`. This method is used to implement the `format` functionality, but it can also be used to format arbitrary numbers programmatically.
      Parameters:
        `number` - The number to format
        `format` - The format to apply. See `FormatString`
      Returns:
        formatted number string

    - #### format

          public static java.lang.String format(java.lang.Integer number,
                                                java.lang.String format)

      Return the parameter number formatted according to the parameter `FormatString`. This method is used to implement the `format` functionality, but it can also be used to format arbitrary numbers programmatically.
      Parameters:
        `number` - The number to format
        `format` - The format to apply. See `FormatString`
      Returns:
        formatted number string

    - #### format

          public static java.lang.String format(java.lang.Float number,
                                                java.lang.String format)

      Return the parameter number formatted according to the parameter `FormatString`. This method is used to implement the `format` functionality, but it can also be used to format arbitrary numbers programmatically.
      Parameters:
        `number` - The number to format
        `format` - The format to apply. See `FormatString`
      Returns:
        formatted number string

    - #### format

          public static java.lang.String format(java.lang.Double number,
                                                java.lang.String format)

      Return the parameter number formatted according to the parameter `FormatString`. This method is used to implement the `format` functionality, but it can also be used to format arbitrary numbers programmatically.
      Parameters:
        `number` - The number to format
        `format` - The format to apply. See `FormatString`
      Returns:
        formatted number string