Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Sum is incorrect in Equation question type

More
2 years 3 months ago #223922 by utkb
Please help us help you and fill where relevant:
Your LimeSurvey version: LimeSurvey Cloud Version 5.2.10
Own server or LimeSurvey hosting: LimeSurvey hosting
Theme: Fruity Theme
==================

Hello,

I want to calculate score of a questionnaire and used Equation quastiontype for this. Each item in this questionnaire have an special weight so I used this equation:

{G12Q61_SQ005.value*22.37+G12Q61_SQ013.value*12.57+G12Q61_SQ022.value*27.26+G12Q61_SQ029.value*16.1+G12Q61_SQ033.value*21.7}

When every value equal to 1, total score must be 100 but result of limesurvey is 100.00000000000001.

What am i doing wrong? Could you help me?

 
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 months ago - 2 years 3 months ago #223949 by Joffm
Replied by Joffm on topic Sum is incorrect in Equation question type
Hi,

What am i doing wrong? 

Nothing.

Could you help me?

No.

Why?
This is an issue of floating point arithmetic.

You may read here.
[url] floating-point-gui.de/ [/url]

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 3 months ago by Joffm.
The following user(s) said Thank You: DenisChenu, utkb
The topic has been locked.
  • tammo
  • tammo's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
2 years 3 months ago #223951 by tammo
Replied by tammo on topic Sum is incorrect in Equation question type
Since this is the result of floating point arithmatics, I would round the result like this:

{round((G12Q61_SQ005.value*22.37+G12Q61_SQ013.value*12.57+G12Q61_SQ022.value*27.26+G12Q61_SQ029.value*16.1+G12Q61_SQ033.value*21.7),0)}


Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
The following user(s) said Thank You: DenisChenu, utkb
The topic has been locked.
More
2 years 3 months ago - 2 years 3 months ago #223953 by utkb
Thank you very much.
Last edit: 2 years 3 months ago by utkb.
The topic has been locked.
More
2 years 3 months ago #223972 by utkb

Since this is the result of floating point arithmatics, I would round the result like this:

{round((G12Q61_SQ005.value*22.37+G12Q61_SQ013.value*12.57+G12Q61_SQ022.value*27.26+G12Q61_SQ029.value*16.1+G12Q61_SQ033.value*21.7),0)}
We use ,0 as precission so i used 2.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose