Project

Profile

Help

Bug #5622

closed

SaxonCS 11.4.0 - Division function generating 50 decimal places

Added by Vijay Bhushan over 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Internals
Sprint/Milestone:
-
Start date:
2022-07-29
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
11, trunk
Fix Committed on Branch:
11, trunk
Fixed in Maintenance Release:
Platforms:
.NET

Description

I am using C# API and I was comparing some transform result between Saxon9h and SaxonCS 11.4.0 where I found difference in decimal places. In new SaxonCS number of digits in scale are 50 where as in previous version Saxon9h was only 21 digits, refer below results.

Transform Result from Saxon9h : <Quote_ProcessedTime Val="194.45083333333333333333"/>

Transform Result from SaxonCS : <Quote_ProcessedTime Val="194.450833333333333333333333333333333333333333333333"/>

Can you please suggest has this been increase purposely or this needs to be fixed in next release? I have attached xslt for your reference.


Files

DivisionTest.xslt (542 Bytes) DivisionTest.xslt Vijay Bhushan, 2022-07-29 07:41
Actions #1

Updated by Michael Kay over 2 years ago

Thanks for reporting it. SaxonCS is using a completely different software library to support decimal arithmetic; we didn't go out of our way to change the default precision for decimal division, but it's not surprising that it's changed, and the XPath specification doesn't require a specific number of digits. You can round the value to any precision you like using the round (or round-half-to-even) function, and there's also a Saxon extension function saxon:decimal-divide that gives a user-specified precision.

We'll think about changing the code to do what the documentation for saxon:decimal-divide says we do:

(The default for decimal division in Saxon using the div operator is to return max(18, s1, s2) decimal places in the result, where s1 is the scale of the first operand and s2 the scale of the second.)

Alternatively, we'll update the documentation. (In fact we need to do that anyway, because the Singulink library that we use in SaxonCS doesn't have the concept of the "scale" of a decimal value.)

Actions #2

Updated by Michael Kay about 2 years ago

  • Category set to Internals
  • Status changed from New to Resolved
  • Assignee set to Michael Kay
  • Priority changed from Low to Normal
  • Applies to branch trunk added
  • Fix Committed on Branch trunk added

I have changed the implementation of decimal division to use 18 digits of precision so we get the same results as SaxonJ.

Actions #3

Updated by O'Neil Delpratt almost 2 years ago

  • Fixed in Maintenance Release 12.0 added
  • Fixed in Maintenance Release deleted (11.4)

Bug issue fix applied in the Saxon 12.0 Major Release. Leaving this bug marked as Resolved until fix applied on the Saxon 11 branch.

Actions #4

Updated by O'Neil Delpratt almost 2 years ago

  • Fixed in Maintenance Release 11.5 added

Bug applied in the Saxon 11.5 Maintenance release.

Actions #5

Updated by O'Neil Delpratt almost 2 years ago

  • Status changed from Resolved to Closed

Please register to edit this issue

Also available in: Atom PDF