Description
Calculate type question behaves differently on certain numbers and creates unnecessary decimal digits.
Related: Decimal creating more digit in decimal part
Steps to Reproduce
A)
Create an integer type question (Q1)
Create a calculate question (C1) with a simple ${Q1} * 1.1 formula.
Create a note to display ${C1}
Write 100 to Q1.
The note displays 110.00000000000001 instead of 110
B)
Create two decimal questions Q2 and Q3
Create a calculate question (C4) with a simple ${Q2} + ${Q3} formula.
Create a note to display ${C4}.
Write 2.32 and 1.32 to Q2 and Q3.
The note displays 3.6399999999999997 instead of 3.64
Expected behavior
The expected behavior is to calculate works same in every number.
Actual behavior
The calculate works different for some numbers. See screenshots for different behaviors:
Additional details
So far, I’ve tested and confirmed that these numbers create some sort of problem in the following calculation: integer * 1.1 : “3, 6, 7, 11, 12, 100, 200, 400, 700, 800”
There is a form where you can check additional calculations:
Enketo Express for KoboToolbox
There is an xlsform with additional operators. Feel free to check it yourselves:
Calculate Problems.xlsx (10.1 KB)
Dnes
May 18, 2022, 5:09am
2
we can use the round-off.
Hi,
The truncate function does not seem to be working in Kobo. I want to round off the value to the lowest integer value. For example, 5.7 should be rounded off to 5.
Is there a way to do this on Kobo?
Jan_L
May 18, 2022, 2:06pm
3
I have done this, but it mess up other number that doesnot need to be round off tho,
I don’t think rounding-off always would solve the issue for everyone.
Okard
July 12, 2022, 3:10am
5
Hi @hakan_cetinkaya , do you find any solution?
@Kal_Lam would you mind suggesting please?
@Okard , Unfortunately not.
You can see another occurance of this bug in @Kal_Lam ’s answer, see the second screenshot, it should be:
0.98 - 0.91 = 0.07
but it is
0.98 - 0.91 = 0.0699999999995
@prasenjit_mondal , you should be able to do this by following the instructions outlined below:
In the survey tab of your XLSForm:
[image]
Data entry screen as seen in Enketo: _when the difference is less than 0.5)
[image]
Data entry screen as seen in Enketo: _when the difference is greater than 0.5)
[image]
Reference XLSForm:
Absolute Value.xlsx (8.5 KB)
You can see another variance of this bug when @inigo-blonk tried to use:
99.3 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 as a calculation.
in here:
Description
When using a calculate number as a relevant, the number is not well calculated.
Steps to Reproduce
…Use a sum calculate based on a decimal inputs of a number of questions
…In this case the numbers asked for are supposed to add to a 100
…The result number is 99.9999999
Expected behavior
The sum of the numbers should match the sum of the inputs
Actual behavior
The number adds up to a number not correct
[check-kobo]