Calculation not rounding off as expected in app

Good day
In my XLS form I have a "calculate" line.

calculate Tripdistance round((${Odo_stop} -
${Odo_start}),2)

The entered values Odo_stop and Odo_start is decimal values.

To display the value I have this line at the end of the form:

note Trip_detail Your trip to
${Destination} was ${Tripdistance} km.

The form validate correctly, upload and work as expected in Enketo forms
but not in the ODK app.
.
I expect this output to display to the user.

Your trip to XYZ was 354.65 km

It shows

Your trip to XYZ was 354.6549456372911677

How can I fix this? I've tried the round() with or without extra brackets.
What's more, only two decimal places were used as input to Odo_stop and
Odo_start.

Here is the line from the generated .xml form

Regards

Decimal numbers are represented internally in binary floating point.
The conversion from decimal to binary will sometimes introduce
rounding errors. See
https://groups.google.com/d/msg/opendatakit/vmy2dPfxlS0/HCFDniUbOs4J
for Mitch's explanation.

There's currently no easy solution without someone writing code (e.g.,
an improved substring to truncate?). Perhaps you can make this
contribution to the Javarosa library that powers ODK?

Yaw

ยทยทยท -- Need ODK services? http://nafundi.com provides form design, server setup, professional support, and software development for ODK.

On Tue, Aug 25, 2015 at 10:00 AM, Bergie bergie5737@gmail.com wrote:

Good day
In my XLS form I have a "calculate" line.

calculate Tripdistance round((${Odo_stop} -
${Odo_start}),2)

The entered values Odo_stop and Odo_start is decimal values.

To display the value I have this line at the end of the form:

note Trip_detail Your trip to
${Destination} was ${Tripdistance} km.

The form validate correctly, upload and work as expected in Enketo forms but
not in the ODK app.
.
I expect this output to display to the user.

Your trip to XYZ was 354.65 km

It shows

Your trip to XYZ was 354.6549456372911677

How can I fix this? I've tried the round() with or without extra brackets.
What's more, only two decimal places were used as input to Odo_stop and
Odo_start.

Here is the line from the generated .xml form

Regards

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.