Name

number( )

Synopsis

                     number number( )
number number(object o)

The number( ) function converts its argument to a number according to these rules:

  • A string is converted by first stripping leading and trailing whitespace and then picking the IEEE 754 value that is closest (according to the IEEE 754 round-to-nearest rule) to the mathematical value represented by the string. If the string does not seem to represent a number, it is converted to NaN. Exponential notation (e.g., 75.2E-12) is not recognized.

  • True Booleans are converted to 1; false Booleans are converted to 0.

  • Node-sets are first converted to the string-value of the first node in the set. This string is then converted to a number.

If the argument is omitted, then it converts the context node.

Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.