Ext.Number

Files

A collection of useful static methods to deal with numbers

Defined By

Methods

Ext.Number
view source
( number, min, max ) : Number
Checks whether or not the passed number is within a desired range. ...

Checks whether or not the passed number is within a desired range. If the number is already within the range it is returned, otherwise the min or max value is returned depending on which side of the range is exceeded. Note that this method returns the constrained value but does not change the current number.

Parameters

  • number : Number

    The number to check

  • min : Number

    The minimum number in the range

  • max : Number

    The maximum number in the range

Returns

  • Number

    The constrained value if outside the range, otherwise the current value

Ext.Number
view source
( value, defaultValue ) : Number
Validate that a value is numeric and convert it to a number if necessary. ...

Validate that a value is numeric and convert it to a number if necessary. Returns the specified default value if it is not.

Ext.Number.from('1.23', 1); // returns 1.23 Ext.Number.from('abc', 1); // returns 1

Parameters

  • value : Object
  • defaultValue : Number

    The value to return if the original value is non-numeric

Returns

  • Number

    value, if numeric, defaultValue otherwise

Ext.Number
view source
( value, increment, minValue, maxValue ) : Number
Snaps the passed number between stopping points based upon a passed increment value. ...

Snaps the passed number between stopping points based upon a passed increment value.

Parameters

  • value : Number

    The unsnapped value.

  • increment : Number

    The increment by which the value must move.

  • minValue : Number

    The minimum value to which the returned value must be constrained. Overrides the increment..

  • maxValue : Number

    The maximum value to which the returned value must be constrained. Overrides the increment..

Returns

  • Number

    The value of the nearest snap target.

Ext.Number
view source
( value, precision )
Formats a number using fixed-point notation ...

Formats a number using fixed-point notation

Parameters

  • value : Number

    The number to format

  • precision : Number

    The number of digits to show after the decimal point