Mike said:

  *   That error can be avoided by switching to floating point math.
  *
  *   dfdl:inputValueCalc="{ xs:string(202996.0 div 524287.0) }"
  *
  *   All I did was add ".0" at the end of the numbers to make them floating 
point.

Thanks Mike. I made that change and now it works perfectly.

/Roger

From: Mike Beckerle <mbecke...@apache.org>
Sent: Tuesday, January 2, 2024 8:40 AM
To: users@daffodil.apache.org
Subject: Re: Non-terminating decimal expansion; no exact representable decimal 
result

That error can be avoided by switching to floating point math. dfdl: 
inputValueCalc="{ xs: string(202996. 0 div 524287. 0) }" All I did was add ". 
0" at the end of the numbers to make them floating point. The error is happening
ZjQcmQRYFpfptBannerStart
ZjQThat error can be avoided by switching to floating point math.

dfdl:inputValueCalc="{ xs:string(202996.0 div 524287.0) }"

All I did was add ".0" at the end of the numbers to make them floating point.

The error is happening long before rounding applies. It's the "div" operator 
failing here since div on two integers produces a decimal number.

On Fri, Dec 29, 2023 at 7:54 AM Roger L Costello 
<coste...@mitre.org<mailto:coste...@mitre.org>> wrote:

This element declaration:


<xs:element name="Test" type="xs:string"
    dfdl:textNumberRep="standard"
    dfdl:textStandardBase="10"
    dfdl:textNumberRounding="explicit"
    dfdl:textNumberRoundingMode="roundHalfEven"
    dfdl:inputValueCalc="{ xs:string(202996 div 524287) }"
/>



produces this error message:



Non-terminating decimal expansion; no exact representable decimal result



I got the idea of using roundHalfEven from this Stack Overflow post:



https://stackoverflow.com/questions/4591206/arithmeticexception-non-terminating-decimal-expansion-no-exact-representable



How do I fix the error?


Reply via email to