Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / docs / api / Ext.Number.html
1 <!DOCTYPE html><html><head><title>Ext.Number | Ext JS 4.0 Documentation</title><script type="text/javascript" src="../ext-all.js"></script><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../scrollbars.css" type="text/css"><link rel="stylesheet" href="../docs.css" type="text/css"><link id="styleCss" rel="stylesheet" href="../style.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script><link rel="stylesheet" href="../prettify.css" type="text/css"><!-- link(rel: 'stylesheet', href: req.baseURL + '/css/ext4.css', type: 'text/css')--><link rel="shortcut icon" type="image/ico" href="../favicon.ico"><!--[if IE]>
2 <style type="text/css">.head-band { display: none; }
3 .header { border: 0; top: 0; left: 0px; background: url(../header.gif) repeat-x; }
4 .doc-tab .members .member a.more { background-color: #efefef; }
5 </style><link rel="stylesheet" href="/new/css/ie.css" type="text/css"><![endif]-->
6 </head><body id="ext-body" class="iScroll"><div id="notice" class="notice">For up to date documentation and features, visit 
7 <a href="http://docs.sencha.com/ext-js/4-0">http://docs.sencha.com/ext-js/4-0</a></div><div class="wrapper"><div class="head-band"></div><div class="header"><h2><a href="../index.html">Sencha Documentation</a></h2></div><div id="search"><form><input type="text" placeholder="Search" id="search-field" autocomplete="off" name="q"></form><div id="search-box"></div></div><div id="treePanel"></div><div id="container"><script type="text/javascript">
8
9     req = {
10         liveURL: '.',
11         standAloneMode: true,
12         origDocClass: 'Ext.Number',
13         docClass: 'Ext.Number',
14         docReq: 'Ext.Number',
15         version: '4.0',
16         baseURL: '.',
17         baseDocURL: '.',
18         baseProdURL: '.'
19     };
20
21     clsInfo = {};
22
23
24
25 </script>
26
27 <script type="text/javascript" src="../search.js"></script>
28 <!--script type="text/javascript" src="/new/javascripts/app/examples.js"></script-->
29 <script type="text/javascript" src="../class_tree.js"></script>
30 <script type="text/javascript" src="../class_doc.js"></script>
31 <script type="text/javascript">
32     req.source = 'Number3.html#Ext-Number';
33     clsInfo = {"methods":["constrain","from","toFixed"],"cfgs":[],"properties":[],"events":[],"subclasses":[]};
34     Ext.onReady(function() {
35         Ext.create('Docs.classPanel');
36     });
37 </script><div id="top-block" class="top-block"><h1 id="clsTitle" class="cls"><a href="../source/Number3.html#Ext-Number" target="_blank">Ext.Number</a></h1></div><div id="docContent"><div id="doc-overview-content"><div class="lft"><p>A collection of useful static methods to deal with numbers</p>
38 <div class="members"><div class="m-methods"><a name="methods"></a><div class="definedBy">Defined By</div><h3 class="mth p">Methods</h3><div id="method-constrain" class="member f ni"><a href="Ext.Number.html#method-constrain" rel="method-constrain" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.Number.html" class="definedIn docClass">Ext.Number</a><br/><a href="../source/Number3.html#Ext-Number-method-constrain" class="viewSource">view source</a></div><a name="constrain"></a><a name="method-constrain"></a><a href="Ext.Number.html#" rel="method-constrain" class="cls expand">constrain</a>(
39 <span class="pre">Number number, Number min, Number max</span>)
40  : Number</div><div class="description"><div class="short">Checks whether or not the current number is within a desired range.  If the number is already within the
41 range it is ...</div><div class="long"><p>Checks whether or not the current number is within a desired range.  If the number is already within the
42 range it is returned, otherwise the min or max value is returned depending on which side of the range is
43 exceeded. Note that this method returns the constrained value but does not change the current number.</p>
44 <h3 class="pa">Parameters</h3><ul><li><span class="pre">number</span> : Number<div class="sub-desc"><p>The number to check</p>
45 </div></li><li><span class="pre">min</span> : Number<div class="sub-desc"><p>The minimum number in the range</p>
46 </div></li><li><span class="pre">max</span> : Number<div class="sub-desc"><p>The maximum number in the range</p>
47 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Number</span>&nbsp; &nbsp;<p>The constrained value if outside the range, otherwise the current value</p>
48 </li></ul></div></div></div><div id="method-from" class="member ni"><a href="Ext.Number.html#method-from" rel="method-from" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.Number.html" class="definedIn docClass">Ext.Number</a><br/><a href="../source/Number3.html#Ext-Number-method-from" class="viewSource">view source</a></div><a name="from"></a><a name="method-from"></a><a href="Ext.Number.html#" rel="method-from" class="cls expand">from</a>(
49 <span class="pre">Mixed value, Number defaultValue</span>)
50  : Number</div><div class="description"><div class="short">Validate that a value is numeric and convert it to a number if necessary. Returns the specified default value if
51 it i...</div><div class="long"><p>Validate that a value is numeric and convert it to a number if necessary. Returns the specified default value if
52 it is not.</p>
53
54 <p>Ext.Number.from('1.23', 1); // returns 1.23
55 Ext.Number.from('abc', 1); // returns 1</p>
56 <h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : Mixed<div class="sub-desc">
57 </div></li><li><span class="pre">defaultValue</span> : Number<div class="sub-desc"><p>The value to return if the original value is non-numeric</p>
58 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Number</span>&nbsp; &nbsp;<p>value, if numeric, defaultValue otherwise</p>
59 </li></ul></div></div></div><div id="method-toFixed" class="member ni"><a href="Ext.Number.html#method-toFixed" rel="method-toFixed" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.Number.html" class="definedIn docClass">Ext.Number</a><br/><a href="../source/Number3.html#Ext-Number-method-toFixed" class="viewSource">view source</a></div><a name="toFixed"></a><a name="method-toFixed"></a><a href="Ext.Number.html#" rel="method-toFixed" class="cls expand">toFixed</a>(
60 <span class="pre">Number value, Number precision</span>)
61  : void</div><div class="description"><div class="short"><p>Formats a number using fixed-point notation</p>
62 </div><div class="long"><p>Formats a number using fixed-point notation</p>
63 <h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : Number<div class="sub-desc"><p>The number to format</p>
64 </div></li><li><span class="pre">precision</span> : Number<div class="sub-desc"><p>The number of digits to show after the decimal point</p>
65 </div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">void</span>&nbsp; &nbsp;
66 </li></ul></div></div></div></div></div></div></div><div id="pageContent"></div></div></div></div></body></html>