xsl-list
[Top] [All Lists]

Re: Math: Removing X number of zeroes from number Y.

2005-06-06 08:10:18
Dear Andrew,

Thank you ! This works perfectly.

Best Regards,

Ahsan

On 6/6/05, Andrew Welch <ajwelch(_at_)piper-group(_dot_)com> wrote:

I have a fare element that is returned as, for example,
79000. The decimal point value is specified in another
element as for example 2. Therefore the number should be: 790.00

There's a way to do this mathematically:

Where x=DecimalPoint, and y=fare, the forumla would be y/(10^x)

But as far as I know there's no exponential function in XSLT
1.0. I'm using, or rather, _have_ to use MSXML, I can't go
for FXSLT, etc.

It's worth mentioning that fare is of type 'double' and
DecimalPoint is of type 'short'

Anyone have any ideas on how to do this in plain XSL ?


<xsl:value-of select="concat(substring(.,0,string-length(.) - $dp + 1),
'.', substring(.,string-length(.) - $dp + 1))"/>

$dp is the number of decimal places.

cheers
andrew

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




-- 
Muted Musings - http://doubleletter.blogspot.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--