Reputation: 809
I want to truncate all the decimal places using xslt.
The input and expected values are below.
I used
<xsl:value-of select='format-number(17.99, "0")' />
But it gives 18 for 17.99. That mean, this rounding the number.
How can I change xslt so that output message is populating only with truncating decimal places and without rounding? Could you please anyone guide me?
Upvotes: 1
Views: 1414
Reputation: 70648
You can use floor
here
<xsl:value-of select='format-number(floor(17.99), "0")' /> <!-- 17 -->
<xsl:value-of select='format-number(floor(19.01), "0")' /> <!-- 19 -->
<xsl:value-of select='format-number(floor(18.0), "0")' /> <!-- 18 -->
In fact, you might not even need the format-number
here
<xsl:value-of select='floor(17.99)' /> <!-- 17 -->
<xsl:value-of select='floor(19.01)' /> <!-- 19 -->
<xsl:value-of select='floor(18.0)' /> <!-- 18 -->
Upvotes: 1