xs:decimal

Converts $string-var (a string) to a decimal value.

If $string-var is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

Signatures

xs:decimal(xs:string $string-var) —> xs:decimal

Arguments

Data Type
Argument
Description

xs:string

$string-var

Represents the string to convert to a decimal number.

Returns

Returns the decimal value of $string-var.

Examples

Simple

Invoking decimal("2.2") returns the decimal value 2.2 as shown in the following example query:

<decimal>{xs:decimal("2.2")}</decimal> 

The preceding query generates the following result:

<decimal>2.2</decimal> 

Null

Invoking decimal(()) returns an empty sequence. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.

For example, the following example query:

<decimal>{xs:decimal(())}</decimal> 

The preceding query generates the following result:

<decimal/> 

Related Topics

W3C decimal data type description