Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 14th, 2006, 08:26 AM
Registered User
 
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default adding up 2 numbers in xsl

I am using sum to add-up 2 numbers in xsl. The numbers are 4412545665465445 and 8234567890123456. The sum of these should be 12647113555588901.
But the sum in xsl is returned as 12647113555588900. Even when those numbers are more than 16 digits, the sum returns 0s at the end. It means its not able to cater totals of greater than 16 digits and even when the result is more than 16 digits it returns 0s at the end.
I need to add numbers which could be of any length and their sum can be of any length. So how to solve this problem in xsl?
 
Old July 14th, 2006, 08:32 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

XSLT 1.0 numbers are double-precision floating point, so they are held accurately to about 16 decimal places.

If you want higher precision you could use XSLT 2.0 which offers integer and decimal data types. The precision of these is implementation-defined (ewith an 18 digit minimum) but you can choose an implementation such as Saxon which offers infinite precision.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old July 14th, 2006, 08:41 AM
Registered User
 
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for reply.
But i am really new to XSL. So can you let me know how to move to xslt 2.0 or that Saxon ?
 
Old July 14th, 2006, 09:24 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You can find information about the open source version of Saxon at http://saxon.sf.net/

How you move there depends entirely on where you are moving from!

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
regarding adding numbers in xsl umair.aziz XSLT 1 June 24th, 2006 12:12 PM
Adding numbers Hudson40 Excel VBA 3 November 23rd, 2005 03:02 AM
adding numbers gmoney060 Access 1 August 15th, 2004 08:14 PM
Adding numbers kend XSLT 4 June 27th, 2003 12:33 AM
Adding numbers kend XSLT 1 June 26th, 2003 10:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.