Altova Mailing List Archives

Re: format-number

From: "Marrow" <m--a-r-r-o-w@--------------------.--->
Date: 9/3/2004 6:37:00 PM

Use the format-number() function as suggested in your posting subject, e.g.

If you want 4 fixed decimal places...
  <xsl:value-of select="format-number(LastPrice,'0.0000')" />

If you want a maximum of 4 decimal places...

  <xsl:value-of select="format-number(LastPrice,'0.####')" />

However, this will round to the nearest, i.e. 1.1234999999999 will be shown
as 1.1235
So if you want to always round down you will have to floor it yourself, e.g.
  <xsl:value-of select="format-number(floor(LastPrice * 10000) div
10000,'0.0000')" />

Marrow - home of Xselerator (XSLT IDE and debugger)

"Saulot" <saulot@l...> wrote in message
> Hi,
> Got this : <xsl:value-of select="LastPrice" />
> How can I tell my XSL I want the result with 4 digit max. (ie : 1.1234 and
> not 1.1234999999999)
> Thks for help.


These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.