X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6746dc89c47ed01b165cc1152533605f97eb8e8d..f562e4c6e5fac7bcb445985b99acbea4d706e6f0:/docs/output/Number.js diff --git a/docs/output/Number.js b/docs/output/Number.js new file mode 100644 index 00000000..a0abe773 --- /dev/null +++ b/docs/output/Number.js @@ -0,0 +1 @@ +Ext.data.JsonP.Number({"tagname":"class","html":"
Files
Creates a wrapper object to allow you to work with numerical values.
\n\nThe primary uses for the Number
object are:
If the argument cannot be converted into a number, it returns NaN
.
In a non-constructor context (i.e., without the new
operator), Number
can\nbe used to perform a type conversion.
Number
object to assign values to numeric variablesThe following example uses the Number
object's properties to assign values to\nseveral numeric variables:
biggestNum = Number.MAX_VALUE;\nsmallestNum = Number.MIN_VALUE;\ninfiniteNum = Number.POSITIVE_INFINITY;\nnegInfiniteNum = Number.NEGATIVE_INFINITY;\nnotANum = Number.NaN;\n
\n\nNumber
to convert a Date
objectThe following example converts the Date
object to a numerical value using\nNumber
as a function:
var d = new Date(\"December 17, 1995 03:24:00\");\nprint(Number(d));\n
\n\nThis displays \"819199440000\".
\n\nThe following example converts the Date object to a numerical value using\nNumber
as a function:
Special value representing negative infinity; returned on overflow.
\n\nThe value of Number.NEGATIVE_INFINITY
is the same as the negative value of the global object's\nInfinity property.
This value behaves slightly differently than mathematical infinity:
\n\nSeveral JavaScript methods (such as the Number
constructor, parseFloat
, and parseInt
) return\nNaN
if the value specified in the parameter is significantly lower than Number.MIN_VALUE
.
You might use the Number.NEGATIVE_INFINITY
property to indicate an error condition that returns a\nfinite number in case of success. Note, however, that isFinite
would be more appropriate in such\na case.
In the following example, the variable smallNumber is assigned a value that is smaller than the\nminimum value. When the if
statement executes, smallNumber
has the value \"-Infinity\"
, so\nsmallNumber
is set to a more manageable value before continuing.
var smallNumber = (-Number.MAX_VALUE) * 2\nif (smallNumber == Number.NEGATIVE_INFINITY) {\n smallNumber = returnFinite();\n}\n
\nSpecial value representing infinity; returned on overflow.
\n\nThe value of Number.POSITIVE_INFINITY
is the same as the value of the global object's Infinity\nproperty.
This value behaves slightly differently than mathematical infinity:
\n\nSeveral JavaScript methods (such as the Number
constructor, parseFloat
, and parseInt
) return\nNaN
if the value specified in the parameter is significantly higher than Number.MAX_VALUE
.
You might use the Number.POSITIVE_INFINITY
property to indicate an error condition that returns a\nfinite number in case of success. Note, however, that isFinite
would be more appropriate in such\na case.
In the following example, the variable bigNumber
is assigned a value that is larger than the\nmaximum value. When the if statement executes, bigNumber
has the value \"Infinity\", so bigNumber
\nis set to a more manageable value before continuing.
var bigNumber = Number.MAX_VALUE * 2\nif (bigNumber == Number.POSITIVE_INFINITY) {\n bigNumber = returnFinite();\n}\n
\nThe largest positive representable number. The largest negative representable\nnumber is -MAX_VALUE
.
The MAX_VALUE
property has a value of approximately 1.79E+308. Values larger than MAX_VALUE
are\nrepresented as \"Infinity\"
.
Because MAX_VALUE
is a static property of Number
, you always use it as Number.MAX_VALUE
,\nrather than as a property of a Number
object you created.
The following code multiplies two numeric values. If the result is less than or equal to\nMAX_VALUE
, the func1
function is called; otherwise, the func2
function is called.
if (num1 * num2 <= Number.MAX_VALUE)\n func1();\nelse\n func2();\n
\nThe smallest positive representable number -- that is, the positive number\nclosest to zero (without actually being zero). The smallest negative\nrepresentable number is -MIN_VALUE
.
The MIN_VALUE
property is the number closest to 0, not the most negative number, that JavaScript\ncan represent.
MIN_VALUE
has a value of approximately 5e-324. Values smaller than MIN_VALUE
(\"underflow\nvalues\") are converted to 0.
Because MIN_VALUE
is a static property of Number
, you always use it as Number.MIN_VALUE
,\nrather than as a property of a Number
object you created.
The following code divides two numeric values. If the result is greater than or equal to\nMIN_VALUE
, the func1
function is called; otherwise, the func2
function is called.
if (num1 / num2 >= Number.MIN_VALUE)\n func1()\nelse\n func2()\n
\nReturns a string representing the number in exponential notation.
\n\nA string representing a Number
object in exponential notation with one digit before the decimal\npoint, rounded to fractionDigits
digits after the decimal point. If the fractionDigits
argument\nis omitted, the number of digits after the decimal point defaults to the number of digits necessary\nto represent the value uniquely.
If you use the toExponential
method for a numeric literal and the numeric literal has no exponent\nand no decimal point, leave a space before the dot that precedes the method call to prevent the dot\nfrom being interpreted as a decimal point.
If a number has more digits that requested by the fractionDigits
parameter, the number is rounded\nto the nearest number represented by fractionDigits
digits. See the discussion of rounding in the\ndescription of the toFixed
method, which also applies to toExponential
.
var num=77.1234;\n\nalert(\"num.toExponential() is \" + num.toExponential()); //displays 7.71234e+1\n\nalert(\"num.toExponential(4) is \" + num.toExponential(4)); //displays 7.7123e+1\n\nalert(\"num.toExponential(2) is \" + num.toExponential(2)); //displays 7.71e+1\n\nalert(\"77.1234.toExponential() is \" + 77.1234.toExponential()); //displays 7.71234e+1\n\nalert(\"77 .toExponential() is \" + 77 .toExponential()); //displays 7.7e+1\n
\nAn integer specifying the number of digits after the decimal\npoint. Defaults to as many digits as necessary to specify the number.
\nExponential notation of number.
\nReturns a string representing the number in fixed-point notation.
\nThe number of digits to appear after the decimal point; this may be a\nvalue between 0 and 20, inclusive, and implementations may optionally support a larger range of\nvalues. If this argument is omitted, it is treated as 0.
\nA string representation of number
that does not use\nexponential notation and has exactly digits
digits after the decimal place.\nThe number is rounded if necessary, and the fractional part is padded with\nzeros if necessary so that it has the specified length. If number
is greater\nthan 1e+21, this method simply calls Number.toString()
and returns a string\nin exponential notation.
Returns a human readable string representing the number using the locale of the\nenvironment. Overrides the Object.prototype.toLocaleString
method.
This method available to numbers will convert the number into a string which is suitable for\npresentation in the given locale.
\n\nvar number = 3500\nconsole.log(number.toLocaleString()); // Displays \"3,500\" in English locale\n
\nString representing the number.
\nReturns a string representing the number to a specified precision in fixed-\npoint or exponential notation.
\n\nA string representing a Number
object in fixed-point or\nexponential notation rounded to precision significant digits. See the\ndiscussion of rounding in the description of the toFixed
method, which also\napplies to toPrecision
.
If the precision argument is omitted, behaves as Number.toString. If it is a\nnon-integer value, it is rounded to the nearest integer. After rounding, if\nthat value is not between 1 and 100 (inclusive), a RangeError is thrown.
\nAn integer specifying the number of significant digits.
\nString that represents Number
object.
Returns a string representing the specified object. Overrides the\nObject.prototype.toString
method.
The Number
object overrides the toString
method of the Object
object; it does not inherit\nObject.toString
. For Number
objects, the toString method returns a string representation of the\nobject in the specified radix.
The toString
method parses its first argument, and attempts to return a string representation in\nthe specified radix (base). For radixes above 10, the letters of the alphabet indicate numerals\ngreater than 9. For example, for hexadecimal numbers (base 16), A through F are used.
If toString
is given a radix not between 2 and 36, an exception is thrown.
If the radix is not specified, JavaScript assumes the preferred radix is 10.
\n\nvar count = 10;\nprint(count.toString()); // displays \"10\"\nprint((17).toString()); // displays \"17\"\n\nvar x = 7;\nprint(x.toString(2)); // displays \"111\"\n
\nAn integer between 2 and 36 specifying the base to use for representing\nnumeric values.
\nThe number represented as a string.
\nReturns the primitive value of the specified object. Overrides the\nObject.prototype.valueOf
method.
The valueOf
method of Number
returns the primitive value of a Number
object as a number data\ntype.
This method is usually called internally by JavaScript and not explicitly in code.
\n\nvar x = new Number();\nprint(x.valueOf()); // prints \"0\"\n
\nThe primitive value of the number.
\n