Happened upon a discrepancy in XPath2Evaluate compared to System.Xml.XPath.Evaluate which I think might be a bug. XPath2Evaluate seems to round 2.5 down to 2, while Evaluate rounds it up to 3.
[TestClass]
public class RoundTests
{
[TestMethod]
public void TwoPointFive()
{
var xpath = "round(number(value))";
var xml = @"<value>2.5</value>";
using (var reader = new StringReader(xml))
{
var doc = XDocument.Load(reader);
var nav = doc.CreateNavigator();
var v1 = nav.Evaluate(xpath); // 3
var v2 = nav.XPath2Evaluate(xpath); // 2
Assert.AreEqual(v1, v2); // Fails
}
}
}
Happened upon a discrepancy in XPath2Evaluate compared to System.Xml.XPath.Evaluate which I think might be a bug. XPath2Evaluate seems to round 2.5 down to 2, while Evaluate rounds it up to 3.
According to the doc examples it seems like rounding up to 3 is the correct behavior: https://www.w3.org/TR/xquery-operators/#func-round
Example test case that fails: