I can't find anything in the XPath specification that discusses precision on xs:decimal division. I did find this Saxon documentation [1] on how they handle it:
> In the case of decimal division, the precision is the sum of the precisions > of the two operands, plus six. I dont' see that in the spec either, so maybe this is implementation defined? It it was up to us, it would probably be nice allow something like xs:decimal(180) div xs:decimal(8388607) to work with a reasonable level of precision without needing to convert to double/float. - Steve [1] https://www.saxonica.com/html/documentation/expressions/arithmetic.html On 9/4/19 1:39 PM, Beckerle, Mike wrote: > Should this produce a decimal, rounded to some number of fraction digits, or > convert to floating point? > > > -------------------------------------------------------------------------------- > *From:* Steve Lawrence <slawre...@apache.org> > *Sent:* Wednesday, September 4, 2019 1:35 PM > *To:* users@daffodil.apache.org <users@daffodil.apache.org> > *Subject:* Re: Non-terminating decimal expansion ... huh? > This seems like a bug in our DFDL expression implementation to me. A > small example that reproduces this is the expression: > > xs:decimal(180) div xs:decimal(8388607) > > But this works on a couple of XPath test implementations I've tried. I'd > guess that Daffodil needs to provide a rounding method so that we don't > get these infinite decimal errors. > > Though, the xs:double does seem like the right workaround. > > > On 9/4/19 1:27 PM, Beckerle, Mike wrote: >> You are doing divisions among integers. >> >> If you want it to convert to floating point you need to be explicit. >> >> Otherwise it tries to keep things as decimal, but clearly that can't work >> for >> division. >> >> I suggest changing your 180 constants to xs:double(180) That should force >> everything to convert into double-precision floating point. >> -------------------------------------------------------------------------------- >> *From:* Costello, Roger L. <coste...@mitre.org> >> *Sent:* Wednesday, September 4, 2019 1:18 PM >> *To:* users@daffodil.apache.org <users@daffodil.apache.org> >> *Subject:* Non-terminating decimal expansion ... huh? >> >> Hello DFDL community, >> >> The below DFDL schema produces this error message: >> >> *[error] Parse Error: Non-terminating decimal expansion; no exact >> representable >> decimal result. (within Expression Evaluation Error: Non-terminating decimal >> expansion; no exact representable decimal result.* >> >> What does that mean? Why am I getting it? How to fix it? /Roger >> >> <xs:elementname="input"> >> <xs:complexType> >> <xs:sequence> >> <xs:elementname="command-code"type="unsignedint3"/> >> <xs:elementname="longitude"> >> <xs:complexType> >> <xs:sequence> >> <xs:elementname="raw"type="unsignedint24"/> >> <xs:elementname="degrees"type="xs:string"dfdl:inputValueCalc="{ >> if (../raw eq 0) then '0 degrees' >> else if (../raw lt 8388607) then >> fn:concat((../raw >> * 180 div 8388607), ' degrees east') >> else fn:concat('-',((../raw - 8388607) * 180 >> div >> 8388607), ' degrees west') >> }"/> >> </xs:sequence> >> </xs:complexType> >> </xs:element> >> <xs:elementname="area-code"type="unsignedint5"/> >> </xs:sequence> >> </xs:complexType> >> </xs:element> >> >