number Function
.NET Framework 4.5
Converts the argument to a number.
number number(object?)
Converts its argument to a number as follows.
-
A string that consists of optional white space followed by an optional minus sign followed by a number followed by white space is converted to the IEEE 754 number that is nearest (according to the IEEE 754 round-to-nearest rule) to the mathematical value represented by the string; any other string is converted to NaN.
-
Boolean true is converted to 1; Boolean false is converted to 0.
-
A node-set is first converted to a string and then converted in the same way as a string argument.
-
An object of a type other than the four basic types (node-set, Boolean, number, or string) is converted to a number in a way that is dependent on that type.
If the argument is omitted, it defaults to a node-set with the context node as its only member.
Note: |
|---|
The number() function should not be used for conversion of numeric data occurring in an element in an XML document unless the element is of a type that represents numeric data in a language-neutral format (that would typically be transformed into a language-specific format for presentation to a user). In addition, the number() function cannot be used unless the language-neutral format used by the element is consistent with the XML Path Language (XPath) syntax for a number. |
XML File
None; the XSLT file calls itself.
XSLT File (number.xsl)
<?xml version='1.0'?> <?xml-stylesheet type="text/xsl" href="number.xsl"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="/"> <html> <body> <h3>number() Function</h3> <ul> <li> <b>number('2048')</b> = <xsl:value-of select="number('2048')"/> </li> <li> <b>number('-2048')</b> = <xsl:value-of select="number('-2048')"/> </li> <li> <b>number('text')</b> = <xsl:value-of select="number('text')"/> </li> <li> <b>number('109.54' div '1')</b> = <xsl:value-of select="number('109.54' div '1')"/> </li> </ul> </body> </html> </xsl:template> </xsl:stylesheet>
Formatted Output
number() Function
number('2048') = 2048
number('-2048') = -2048
number('text') = NaN
number('109.54') = 109.54
Processor Output
<html>
<body>
<h3>number() Function</h3>
<ul>
<li><b>number('2048')</b>
=
2048</li>
<li><b>number('-2048')</b>
=
-2048</li>
<li><b>number('text')</b>
=
NaN</li>
<li><b>number('109.54' div '1')</b>
=
109.54</li>
</ul>
</body>
</html>
Build Date:
Note: