{infiniteZest}
// Articles. Tutorials. Utilities.
Home  |   Search  |   Login  
Categories Skip Navigation Links
New / All
AJAX
Apple
ASP.NET
.NET
Git
Google / Android
Python / IronPython
Miscellaneous
SQL Server
AJAX Source Viewer
View the source code of a Method from ASP.NET AJAX Library. Choose a method from the menu items above (Namespaces, Classes, or Methods).
Method '_parse(value, cultureInfo)'
Method: _parse(value, cultureInfo)
Method Full Name:     Number$_parse(value, cultureInfo)
Class: Number
Namespace: Global (MicrosoftAjax.debug.js)
Source File: MicrosoftAjax.debug.js
1   Number._parse = function Number$_parse(value, cultureInfo) {
2     value = value.trim();
3     
4     if (value.match(/^[+-]?infinity$/i)) {
5       return parseFloat(value);
6     }
7     if (value.match(/^0x[a-f0-9]+$/i)) {
8       return parseInt(value);
9     }
10    var numFormat = cultureInfo.numberFormat;
11    var signInfo = Number._parseNumberNegativePattern(value, numFormat, numFormat.NumberNegativePattern);
12    var sign = signInfo[0];
13    var num = signInfo[1];
14    
15    if ((sign === '') && (numFormat.NumberNegativePattern !== 1)) {
16      signInfo = Number._parseNumberNegativePattern(value, numFormat, 1);
17      sign = signInfo[0];
18      num = signInfo[1];
19    }
20    if (sign === '') sign = '+';
21    
22    var exponent;
23    var intAndFraction;
24    var exponentPos = num.indexOf('e');
25    if (exponentPos < 0) exponentPos = num.indexOf('E');
26    if (exponentPos < 0) {
27      intAndFraction = num;
28      exponent = null;
29    }
30    else {
31      intAndFraction = num.substr(0, exponentPos);
32      exponent = num.substr(exponentPos + 1);
33    }
34    
35    var integer;
36    var fraction;
37    var decimalPos = intAndFraction.indexOf(numFormat.NumberDecimalSeparator);
38    if (decimalPos < 0) {
39      integer = intAndFraction;
40      fraction = null;
41    }
42    else {
43      integer = intAndFraction.substr(0, decimalPos);
44      fraction = intAndFraction.substr(decimalPos + numFormat.NumberDecimalSeparator.length);
45    }
46    
47    integer = integer.split(numFormat.NumberGroupSeparator).join('');
48    
49    var p = sign + integer;
50    if (fraction !== null) {
51      p += '.' + fraction;
52    }
53    if (exponent !== null) {
54      var expSignInfo = Number._parseNumberNegativePattern(exponent, numFormat, 1);
55      if (expSignInfo[0] === '') {
56        expSignInfo[0] = '+';
57      }
58      p += 'e' + expSignInfo[0] + expSignInfo[1];
59    }
60    if (p.match(/^[+-]?\d*\.?\d*(e[+-]?\d+)?$/)) {
61      return parseFloat(p);
62    }
63    return Number.NaN;
64  }
This is the JavaScript source for method _parse(value, cultureInfo) from ASP.NET AJAX Library. Full name for this method is Number$_parse(value, cultureInfo). It belongs to the class Number, which is in Global (MicrosoftAjax.debug.js) namespace. This source is in MicrosoftAjax.debug.js file.
Bookmark and Share This
About  Contact  Privacy Policy  Site Map