• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XSL mod Operation gives wrong result due to large value

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

I want to perform modulus operation on the XSL variable having value, more than XSD:unsignedLong datatype. (For Eg: 2100041810000023014509 mod 97)
My current implementation is:



But, <result> tag displays wrong result.
According to me, the wrong result is due to the large value.

Is there any other way to perform mod operation in XSL?

Thanks In Advance,
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You omitted to say what the answer was according to you and what the answer was according to XSLT and why you were right and XSLT was wrong.
 
Dhaval Hansaliya
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul,

Thanks for replay...

Actual result for the mod operation of 2100041810000023014509 digit (2100041810000023014509 mod 97) = 32
But, when i assign this value to variable (Lets say sum) and perform same operation ($sum mod 97), i am getting the result = 86
This wrong output is because of modulo operation on the integer number, which is larger than the data type range.

Now, I have written templates in XSL file which divides the input number in small segments and perform modulo operations on each segments.


Still, update me, if there is an easier method available in the XSL to perform same operation.

thanks,
-Dhaval
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I get 32 from my Windows calculator too.

I didn't want to say that XSLT was "wrong" to come up with something else because I remember some complaints from way back when XSLT was first designed. My recollection was that people who tried to write transformers in a language other than Java claimed they were at a disadvantage because the spec said (essentially) that XSLT had to do arithmetic exactly as Java did it.

But now I can't find any evidence of that on the web. However, I'm pretty sure your theory about why XSLT gets the wrong answer for that calculation is right. Unfortunately I don't have any advice for you about how to get the right answer.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic