View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 07126 | Bug reports | Expression Manager | public | 2013-01-02 11:47 | 2013-01-03 09:15 |
| Reporter | chops | Assigned To | c_schmitz | ||
| Priority | normal | Severity | minor | ||
| Status | closed | Resolution | no change required | ||
| Product Version | 2.00+ | ||||
| Summary | 07126: 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. | ||||
| Tags | No tags attached. | ||||
| Attached Files | |||||
| Bug heat | 6 | ||||
| Complete LimeSurvey version number (& build) | 121231 | ||||
| I will donate to the project if issue is resolved | No | ||||
| Browser | |||||
| Database type & version | MySQL 5.5 | ||||
| Server OS (if known) | Ubuntu | ||||
| Webserver software & version (if known) | Apache2 | ||||
| PHP Version | 5 | ||||
| Git branch / Pull Request URL | |||||
|
Hi Thomas, any quick thought on this? |
|
|
Does it work in 1.92? It should as i tested fractions there extensively. |
|
|
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? |
|
|
yes, the problem is that comma is being used as the decimal separator. So, you get: sum(LEMval(a), LEMval(b), ...), which translates to 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. |
|
|
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!!! |
|
|
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. |
|
|
Added hint to the documentation for equation question type. |
|
| 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 |