Decimal creating more digit in decimal part

Hi,

I am working on the agriculture related project.

We have the questions asking about farmer land use in the order

  1. How many hectare of cultivated land you have ? answer in decimal
    1.1 How many hectare of CROP 1 cultivated land you have? answer in decimal
    1.2 How many hectare of CROP 2 cultivated land you have? answer in decimal

To validate the land - 1.1 +1.2 = 1 if not it showed the message that they need to redo it

We started having problem when data collector answer as :

  1. How many hectare of cultivated land you have ? 2.64
    1.1 How many hectare of CROP 1 cultivated land you have? 2.32
    1.2 How many hectare of CROP 2 cultivated land you have? 0.32

But the validating message showed the sum of 1.1. and 1.2 as: 2.6399999999999997
which has 13th decimal- and this is not match with the total number which inputted in 1 which is 2.64

Hope that you guys can helps,

Jen

Hello @Jan_L,
Could you provide an extract of the related form part and a screenshot with data entry and mesaage, please?

1 Like

Hi @wroos,

Here is my screenshot, and also attached is the xls form ,

Hope you can help,

Jen
Rice_Production_9May2022.xlsx (87.0 KB)

@Jan_L, maybe this post discussed previously should help you solve your issue:

Thank you @Kal_Lam

The problem is that the form create 13 digits after decimal when I enter only 2 digits after decimal.

I enter 2.32, and 0.32 which expected the output (2.32 +0.32= 2.64) but Kobo generate this 2.63999999999997

I dont know why and how to solve this,
Best,

@Kal_Lam

I took a screenshot here, you can see the differences between other number


The have tried round up but it messed with other number, howcan I tell Kobo to take exact number that input when it has x.x2 + x.x2

Hope you can helps,
Jen

Hi @Jan_L,

I’ve created a bug report in here including the problem you’re facing too:

Feel free to test and provide additional details.
Best,

1 Like

Thanks for additional point, :slight_smile:

1 Like

@Jan_L, could you also test this with the Collect android app to see if it behaves differently than Enketo? cc: @hakan_cetinkaya

Hi @Kal_Lam

Yes, the data collector using this on collect app and having the same issue.

Best

1 Like

Hello @Kal_Lam

Do you have any update on this?

Best,

Hello @Okard,

  • Would you mind to share the related part of your form, please.
  • Could you test the issue on Collect, as Kal_Lam suggested?
  • Do you have the same issue when you uae a decimal instead of the calculate type?
  • What was the problem when you used round()?
2 Likes

Hello @wroos

Please see the attached for the form,

You can reproduce the problem with -

Yes, I am using both collect and Enketo to test, and it produce the same problem.

When I used round up the problem is with the number that I dont want to round them up like 3.98. I dont want them to be 4 for example

Best,
Okard
Rice_Production_9May2022.xlsx (87.1 KB)

Hello,
Did you try round(YourDecimal, 2)?
See https://getodk.github.io/xforms-spec/#fn:round.

2 Likes

Hi @wroos ,

Sorry for late response. I did use the round up for the input in _1_1 , _1_2, _1_3, and 1_4 and the response was incorrect and it was when I think round up was not the function :expressionless:

But I have removed them from the mentioned question, and only use round up with result of the sum (_1_1 + _1_2 + _1_3 + _1_4) and it works.

Hope that the enumerator will not add more than 2 digits:) , thanks for your help a lot.

Best,
Okard