VextoR
VextoR

Reputation: 5165

xslt dividing returns number with E

In xslt when I divide numbers, like

<xsl:value-of select="number( $field ) div number( $factor )"/>

result value can contain E (10 power) like 8.004091E9

How to make it return proper value => 8004091000 without Es ?

Upvotes: 1

Views: 1354

Answers (1)

Michael Kay
Michael Kay

Reputation: 163458

In XSLT 1.0, the output should never be in scientific notation, so I assume you are using XSLT 2.0.

In XSLT 2.0, the output should be in scientific notation if (a) it's a float or double, (b) its absolute value is outside the range 1e-6 to 1e+6.

One way to avoid getting output in scientific notation is to format it using format-number().

Another way is to avoid floating point: for example, in place of

<xsl:value-of select="number( $field ) div number( $factor )"/>

use

<xsl:value-of select="xs:decimal( $field ) div xs:decimal( $factor )"/>

Upvotes: 2

Related Questions