View Issue Details

This issue affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
07126Bug reportsExpression Managerpublic2013-01-03 09:15
Reporterchops Assigned Toc_schmitz  
PrioritynormalSeverityminor 
Status closedResolutionno change required 
Product Version2.00+ 
Summary07126: Equation: No sum for calculated float numbers
Description

The calculation for {sum(0.5, 0.5, 0.5, 0.5)} works.

XX_E11a - XX_E11d are equations and can be 0.5, too. But the equation {sum(XX_E11a.NAOK, XX_E11b.NAOK, XX_E11c.NAOK, XX_E11d.NAOK)} is always 0.

If the equations of XX_E11a - XX_E11d are not set to 0.5 but to 1, the equation {sum(XX_E11a.NAOK, XX_E11b.NAOK, XX_E11c.NAOK, XX_E11d.NAOK)} is calculated correctly.

TagsNo tags attached.
Attached Files
sum_float.lss (21,771 bytes)
Bug heat6
Complete LimeSurvey version number (& build)121231
I will donate to the project if issue is resolvedNo
Browser
Database type & versionMySQL 5.5
Server OS (if known)Ubuntu
Webserver software & version (if known)Apache2
PHP Version5
Git branch / Pull Request URL

Users monitoring this issue

There are no users monitoring this issue.

Activities

c_schmitz

c_schmitz

2013-01-02 23:01

administrator   ~23415

Hi Thomas, any quick thought on this?

TMSWhite

TMSWhite

2013-01-02 23:09

reporter   ~23416

Does it work in 1.92? It should as i tested fractions there extensively.

c_schmitz

c_schmitz

2013-01-02 23:49

administrator   ~23417

Nope, does not work in 1.92 either.

I think that that you need to indicate that the result of the equation is a number by setting it in the advanced question settings to 'Number only' so the decimal mark conversion takes place properly.

Thomas, am I right?

TMSWhite

TMSWhite

2013-01-03 01:04

reporter   ~23418

yes, the problem is that comma is being used as the decimal separator. So, you get:

sum(LEMval(a), LEMval(b), ...), which translates to
sum('0,5', '0,5', ...)

One option is to have LEMval() try to return a number when it sees '0,5'; but that doesn't work well for Equation question types, since they can store numbers or text (so the user might have a text value listing several answers, like '1,2,3' and not want that converted to a number). If we were to add an attribute to the Equation question type to declare it as a number, then we could reliably have LEMval() do that operation.

For this user, I would recommend using 1 and 0 instead of 0.5 and 0; then divide the sum by 2 to get the desired final value. That way decimal values are avoided.

kadejo

kadejo

2013-01-03 01:22

reporter   ~23420

Last edited: 2013-01-03 01:23

Thank you Thomas!!!, I had this problem too, and when setting '.' as decimal separator at survey config, then calculations worked with floats perfect as expected.

Fortunately for our american spanish locale that is right, but maybe that is not nice in european cuntries: http://en.wikipedia.org/wiki/Decimal_mark#Countries_using_Arabic_numerals_with_decimal_comma

Anyway thank you, EM rocks!!!

c_schmitz

c_schmitz

2013-01-03 08:57

administrator   ~23425

Thomas, there is already a question attribute 'numbers only' at the equation question type which exactly does it. I activated it for the attached text survey and then it worked fine. Adding a hint to the documentation should do just fine, I think.

c_schmitz

c_schmitz

2013-01-03 09:15

administrator   ~23426

Added hint to the documentation for equation question type.

Issue History

Date Modified Username Field Change
2013-01-02 11:47 chops New Issue
2013-01-02 11:47 chops File Added: sum_float.lss
2013-01-02 23:01 c_schmitz Note Added: 23415
2013-01-02 23:01 c_schmitz Assigned To => TMSWhite
2013-01-02 23:01 c_schmitz Status new => feedback
2013-01-02 23:09 TMSWhite Note Added: 23416
2013-01-02 23:49 c_schmitz Note Added: 23417
2013-01-03 01:04 TMSWhite Note Added: 23418
2013-01-03 01:22 kadejo Note Added: 23420
2013-01-03 01:23 kadejo Note Edited: 23420
2013-01-03 08:57 c_schmitz Note Added: 23425
2013-01-03 09:15 c_schmitz Note Added: 23426
2013-01-03 09:15 c_schmitz Status feedback => closed
2013-01-03 09:15 c_schmitz Assigned To TMSWhite => c_schmitz
2013-01-03 09:15 c_schmitz Resolution open => no change required