In this example we consider a calculation question where numerical answer **10** for Question A is divided by numerical answer **3** for Question B and the result comes out to a default value of **3.3333333333333335**. The desired output format may be **3.3, 3.33 or 3.333**.

In the Question Editor, select Text as your question type, and check "Calculated Value".

Be mindful of the Question IDs (follow "click here to view the IDs for this form"). For this example, we will assume the IDs are **Q1** for Question A and **Q2** for Question B. In the Calculated Value text field, the following JavaScript must be added to modify the number of decimal places of the answer value.

For an answer with 1 decimal place:

Math.round((Q1/Q2)*10)/10

For an answer with 2 decimal places:

Math.round((Q1/Q2)*100)/100

For an answer with 3 decimal places:

Math.round((Q1/Q2)*1000)/1000

Please note that for results that do not have decimal places, they will simply be shown as X, not X.0.

## Comments

0 comments

Please sign in to leave a comment.