This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Working with Scientific Notation
- From: David Carlisle <davidc at nag dot co dot uk>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Fri, 4 Oct 2002 17:37:47 +0100
- Subject: Re: [xsl] Working with Scientific Notation
- References: <3D9DBDF3.5090906@aylix.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
probably one of the libraries has something for this, but otherwise
something like
<xsl:template name="s">
<xsl:param name="m"/>
<xsl:param name="e"/>
<xsl:choose>
<xsl:when test="$e=0"><xsl:value-of select="$m"/></xsl:when>
<xsl:when test="$e >0>
<xsl:call-template name="s">
<xsl:param name="m" select="$m * 10"/>
<xsl:param name="e" select="$e - 1""/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$e <0>
<xsl:call-template name="s">
<xsl:param name="m" select="$m div 10"/>
<xsl:param name="e" select="$e + 1""/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:variable name="f">
<xsl:call-template name="s">
<xsl:param name="m" select="substring-before(.,'E')"/>
<xsl:param name="e" select="substring-after(.,'E')""/>
</xsl:call-template>
</xsl;variable>
then use format-number on the result, $f if you want a particular format.
untested...
David
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list