(ML 8.0-3.2)
In my xquery I’m doing this:
let $total := xs:dayTimeDuration("PT6M38.33S")
let $fastest-three := xs:dayTimeDuration("PT4M6.258784S")
let $div := ($fastest-three div $total)
return ($div)
Which returns:
0.6182280621595159793
If I then try to multiple $div by 100 (to get a percent) I get decimal overflow:
[1.0-ml] XDMP-DECOVRFLW: (err:FOAR0002) $div * 100 -- Decimal overflow
Which is not at all expected.
I also noticed that ML 8 does not appear to support the XQuery 3.x two-argument
round() function, e.g., round($div, 2).
Why am I getting a decimal overflow here?
As a test I tried doing the same thing with Saxon 9.7 and XSLT 3:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="3.1">
<xsl:template match="/">
<xsl:variable name="total" as="xs:dayTimeDuration"
select='xs:dayTimeDuration("PT6M38.33S")'/>
<xsl:variable name="fastest-three" as="xs:dayTimeDuration"
select='xs:dayTimeDuration("PT4M6.258784S")'/>
<xsl:variable name="div" as="xs:decimal"
select="$fastest-three div $total"
/>
<result>
div: <xsl:value-of select="$div"/>
$div * 100: <xsl:value-of select="$div * 100"/>
round($div, 2) = <xsl:value-of select="round($div, 2)"/>
</result>
</xsl:template>
</xsl:stylesheet>
Which produces:
<result>
div: 0.61822806215951597921
$div * 100: 61.822806215951597921
round($div, 2) = 0.62</result>
Thanks,
Eliot
--
Eliot Kimber
http://contrext.com
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general